forked from nanoframework/Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
72 lines (60 loc) · 2.17 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//
// Copyright (c) .NET Foundation and Contributors
// See LICENSE file in the project root for full license information.
//
using System;
using System.Diagnostics;
using System.Threading;
namespace SystemRandom.Sample
{
public class Program
{
public static void Main()
{
// instantiate random generator
Random randomGenerator = new Random();
for (; ; )
{
int counter = 0;
// generate block of 10 random integers between 0 and 100
Debug.WriteLine("");
Debug.WriteLine("-- 10 random integers between 0 and 100 --");
while (counter++ < 10)
{
var value = randomGenerator.Next(100);
Debug.WriteLine(value.ToString());
}
counter = 0;
// generate block of 10 random integers between 0 and 999999
Debug.WriteLine("");
Debug.WriteLine("-- 10 random integers between 0 and 999999 --");
while (counter++ < 10)
{
var value = randomGenerator.Next(999999);
Debug.WriteLine(value.ToString());
}
counter = 0;
// generate block of 10 random doubles
Debug.WriteLine("");
Debug.WriteLine("-- 10 random doubles --");
while (counter++ < 10)
{
var value = randomGenerator.NextDouble();
Debug.WriteLine(value.ToString());
}
// fill byte array with 10 random numbers and output
Debug.WriteLine("");
Debug.WriteLine("-- 10 random numbers from array --");
byte[] buffer = new byte[10];
randomGenerator.NextBytes(buffer);
counter = 0;
while (counter < 10)
{
var value = randomGenerator.NextDouble();
Debug.WriteLine(buffer[counter++].ToString());
}
Thread.Sleep(500);
}
}
}
}