<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Shawn's Technical Blog - All Comments</title><link>http://weblogs.asp.net/smehaffie/default.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>re: Random Number in C#, Be careful of some of the samples you find.</title><link>http://weblogs.asp.net/smehaffie/archive/2009/03/15/random-number-in-c-be-careful-of-some-of-the-samples-you-find.aspx#8283232</link><pubDate>Sun, 05 Feb 2012 18:04:56 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8283232</guid><dc:creator>Mike D</dc:creator><description>&lt;p&gt;@Mital Kakaiya &amp;nbsp; &amp;nbsp;your code is not correct here.&lt;/p&gt;
&lt;p&gt;What you are doing is giving users code that, unless used appropriately, will generate the same number.&lt;/p&gt;
&lt;p&gt;c# has a big issue here, and the best way to go is use alternative class. If you have to use Random, the Sleep is about the only way to guarantee randomnes.&lt;/p&gt;
&lt;p&gt;Please be sure of what you say before posting code. Incorrect codee just gets circulated and wastes users time.&lt;/p&gt;
&lt;p&gt;Congrats to smehaffie on seeing the issues of c# Random.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8283232" width="1" height="1"&gt;</description></item><item><title>re: Random Number in C#, Be careful of some of the samples you find.</title><link>http://weblogs.asp.net/smehaffie/archive/2009/03/15/random-number-in-c-be-careful-of-some-of-the-samples-you-find.aspx#8134552</link><pubDate>Sat, 17 Dec 2011 04:02:36 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8134552</guid><dc:creator>Anthony Sycamore</dc:creator><description>&lt;p&gt;How about this:&lt;/p&gt;
&lt;p&gt;public class RandomGlobal&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp;private static Random r;&lt;/p&gt;
&lt;p&gt; &amp;nbsp;public static Random Random&lt;/p&gt;
&lt;p&gt; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;get&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (r == null)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;r = new Random();&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;return r;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;Call e.g. RandomGlobal.Random.NextDouble()&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8134552" width="1" height="1"&gt;</description></item><item><title>re: Social Networking Links using “AddThis” In Community Server Based Blogs</title><link>http://weblogs.asp.net/smehaffie/archive/2009/02/28/social-networking-links-using-addthis-in-community-server-based-blogs.aspx#7899649</link><pubDate>Sat, 06 Aug 2011 11:19:13 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7899649</guid><dc:creator> johncenanss</dc:creator><description>&lt;p&gt;Thanks for providing This article.It help's to people a lot.&lt;/p&gt;
&lt;p&gt; -----------------&lt;/p&gt;
&lt;p&gt;&amp;lt;a href=“&lt;a rel="nofollow" target="_new" href="http://buybacklinks.org.uk"&gt;http://buybacklinks.org.uk&lt;/a&gt;” rel=“dofollow”&amp;gt; Buy Backlinks &amp;lt;/a&amp;gt;&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7899649" width="1" height="1"&gt;</description></item><item><title>re: Social Networking Links using “AddThis” In Community Server Based Blogs</title><link>http://weblogs.asp.net/smehaffie/archive/2009/02/28/social-networking-links-using-addthis-in-community-server-based-blogs.aspx#7856276</link><pubDate>Tue, 05 Jul 2011 05:27:05 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7856276</guid><dc:creator>Rajeev</dc:creator><description>&lt;p&gt;Jaipur trip from delhi - Agra trip , Agra Jaipur Tour , Car Rental , Airport Taxi at Delhi&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7856276" width="1" height="1"&gt;</description></item><item><title>re: Random Number in C#, Be careful of some of the samples you find.</title><link>http://weblogs.asp.net/smehaffie/archive/2009/03/15/random-number-in-c-be-careful-of-some-of-the-samples-you-find.aspx#7854873</link><pubDate>Mon, 04 Jul 2011 07:33:12 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7854873</guid><dc:creator>in need of help</dc:creator><description>&lt;p&gt;hi can somebody please help me, i have to generate 2 random numbers. and have to keep on generating 2 numbers until the 2 numbers are the same. i then have to calculate how many times i had to generate so that the 2 numbers are the same.&lt;/p&gt;
&lt;p&gt;fanx alot&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7854873" width="1" height="1"&gt;</description></item><item><title>re: Random Number in C#, Be careful of some of the samples you find.</title><link>http://weblogs.asp.net/smehaffie/archive/2009/03/15/random-number-in-c-be-careful-of-some-of-the-samples-you-find.aspx#7854872</link><pubDate>Mon, 04 Jul 2011 07:32:05 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7854872</guid><dc:creator>in need of help</dc:creator><description>&lt;p&gt;hi can somebody please help me, i have to generate 2 random numbers. and have to keep on generating 2 numbers until the 2 numbers are the same. i then have to calculate how many times i had to generate so that the 2 numbers are the same.&lt;/p&gt;
&lt;p&gt;fanx alot&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7854872" width="1" height="1"&gt;</description></item><item><title>re: MS Expression Web 4 SuperPreview – Big Disappointment</title><link>http://weblogs.asp.net/smehaffie/archive/2010/06/13/ms-expression-web-4-superpreview-big-disappointment.aspx#7850390</link><pubDate>Sat, 02 Jul 2011 03:16:14 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7850390</guid><dc:creator>Wanda</dc:creator><description>&lt;p&gt;The super preview isn't such a big deal. What I am upset about is that after spending 10 hours trying to get my updated site (from front page to EW 4) that preview means nothing if the published site does not look like the preview. Yes I published the CSS Style sheet and it looks fine from my computer but w3c says it's missing. So where did it go? I published it and it's online in the folders but no banana. &amp;nbsp;Super frustrating. :( &amp;nbsp;I'm sure something is making it invisible or something else is over riding it but what? &amp;nbsp;Anyone else having this problem or know what to do about it? Thank you. &lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7850390" width="1" height="1"&gt;</description></item><item><title>re: Random Number in C#, Be careful of some of the samples you find.</title><link>http://weblogs.asp.net/smehaffie/archive/2009/03/15/random-number-in-c-be-careful-of-some-of-the-samples-you-find.aspx#7832882</link><pubDate>Fri, 17 Jun 2011 19:35:13 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7832882</guid><dc:creator>masoud</dc:creator><description>&lt;p&gt;check the following codes:&lt;/p&gt;
&lt;p&gt; internal static class ppp&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public static Int32 pp = 10;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;class Random&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public float uniform(float a, float b)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;float o, temp;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;System.Random r = new System.Random(ppp.pp);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;temp=(float)r.NextDouble();&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ppp.pp = r.Next(1, 100);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;o = (b - a) * temp + a;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return o;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7832882" width="1" height="1"&gt;</description></item><item><title>re: Random Number in C#, Be careful of some of the samples you find.</title><link>http://weblogs.asp.net/smehaffie/archive/2009/03/15/random-number-in-c-be-careful-of-some-of-the-samples-you-find.aspx#7803989</link><pubDate>Thu, 26 May 2011 03:30:46 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7803989</guid><dc:creator>weblogs.asp.net</dc:creator><description>&lt;p&gt;Random number in c be careful of some of the samples you find.. He-he-he :)&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7803989" width="1" height="1"&gt;</description></item><item><title>re: Random Number in C#, Be careful of some of the samples you find.</title><link>http://weblogs.asp.net/smehaffie/archive/2009/03/15/random-number-in-c-be-careful-of-some-of-the-samples-you-find.aspx#7704248</link><pubDate>Sat, 12 Feb 2011 14:19:24 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7704248</guid><dc:creator>Dustin</dc:creator><description>&lt;p&gt;This uses Date Ticks and uses the last 5 digit in the 17 digit value. (These are the digits that change extremely quickly and are the best way to seed the Random function, other than more advanced &amp;quot;noise&amp;quot; techniques)&lt;/p&gt;
&lt;p&gt;Heres my function for Randomizing numbers.&lt;/p&gt;
&lt;p&gt;public int RandomInt(int intMin, int intMax)&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;long timestamp = Convert.ToInt64((DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)).Ticks);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;int seed = Convert.ToInt32(Convert.ToString(timestamp).Substring(11));&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;Random r = new Random(seed);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;return r.Next(intMin, intMax);&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7704248" width="1" height="1"&gt;</description></item></channel></rss>
