{"id":118,"date":"2011-05-27T19:12:49","date_gmt":"2011-05-27T19:12:49","guid":{"rendered":"http:\/\/devnot.wordpress.com\/?p=118"},"modified":"2015-11-12T23:18:54","modified_gmt":"2015-11-12T22:18:54","slug":"generate-a-random-number-or-byte-array","status":"publish","type":"post","link":"https:\/\/thomas-jansen.eu\/?p=118","title":{"rendered":"Generate a random number (or byte array)"},"content":{"rendered":"<p>To generate a random number use the <em>System.Random.Random<\/em> class<\/p>\n<p>The numbers generated are pseudo random. Typically, using the same seed generates the same value sequences.<\/p>\n<p>The seed can be set in the constructor. If none is set, a time dependent seed is used which should generate more or less random values.<\/p>\n<p>To get a value call the method <em>Next<\/em><\/p>\n<pre>int value = rand.Next();<\/pre>\n<p>or within range 0 &#8211; 255<\/p>\n<pre>int value = rand.Next(255);<\/pre>\n<p>or between 100 and 200<\/p>\n<pre>int value = rand.Next(100, 200);<\/pre>\n<p>a double between 0.0 and 1.0<\/p>\n<pre>double value = rand.NextDouble();<\/pre>\n<p>Or a byte buffer<\/p>\n<pre>Byte data = new Byte[100];\r\n\r\nrand.NextBytes(data);<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>To generate a random number use the System.Random.Random class The numbers generated are pseudo random. Typically, using the same seed generates the same value sequences. The seed can be set in the constructor. If none is set, a time dependent seed is used which should generate more or less random values. To get a value [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[59],"class_list":["post-118","post","type-post","status-publish","format-standard","hentry","category-c","tag-random-value"],"_links":{"self":[{"href":"https:\/\/thomas-jansen.eu\/index.php?rest_route=\/wp\/v2\/posts\/118","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thomas-jansen.eu\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thomas-jansen.eu\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thomas-jansen.eu\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thomas-jansen.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=118"}],"version-history":[{"count":1,"href":"https:\/\/thomas-jansen.eu\/index.php?rest_route=\/wp\/v2\/posts\/118\/revisions"}],"predecessor-version":[{"id":463,"href":"https:\/\/thomas-jansen.eu\/index.php?rest_route=\/wp\/v2\/posts\/118\/revisions\/463"}],"wp:attachment":[{"href":"https:\/\/thomas-jansen.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=118"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thomas-jansen.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=118"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thomas-jansen.eu\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=118"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}