<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" media="screen" href="/styles/xslt/rss.xslt"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:c9="http://channel9.msdn.com">
<channel>
	<title>Channel 9 Forums - Tech Off - Learning C#</title>
	<atom:link rel="self" type="application/rss+xml" href="http://channel9.msdn.com/Forums/rss"></atom:link>
	<image>
		<url>http://mschnlnine.vo.llnwd.net/d1/Dev/App_Themes/C9/images/feedimage.png</url>
		<title>Channel 9 Forums - Tech Off - Learning C#</title>
		<link>http://channel9.msdn.com/Forums</link>
	</image>
	<description>Channel 9 keeps you up to date with the latest news and behind the scenes info from Microsoft that developers love to keep up with. From LINQ to SilverLight – Watch videos and hear about all the cool technologies coming and the people behind them.</description>
	<link>http://channel9.msdn.com/Forums</link>
	<language>en</language>
	<pubDate>Tue, 18 Jun 2013 22:41:07 GMT</pubDate>
	<lastBuildDate>Tue, 18 Jun 2013 22:41:07 GMT</lastBuildDate>
	<generator>Rev9</generator>
	<c9:totalResults>5</c9:totalResults>
	<c9:pageCount>-5</c9:pageCount>
	<c9:pageSize>-1</c9:pageSize>
	<item>
		<title>Tech Off - Learning C#</title>
		<description><![CDATA[<p>Hi I just want to generate a random number between 1 and 3 and post the result to the text of a label on a form, but I cant, ToString the result, can anyone help ?</p><p>privatevoid button1_Click(object sender, EventArgs e)</p><p>&nbsp;&nbsp;{</p><p>&nbsp;&nbsp;Random rnd1 = new Random(3);</p><p>&nbsp;&nbsp;&nbsp;&nbsp;int n;</p><p>&nbsp;&nbsp;&nbsp;&nbsp;n = rnd1.Next();</p><p>&nbsp;&nbsp;&nbsp;&nbsp;this.label1.Text = n.ToString;</p><p>&nbsp; }</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/Learning-C/58cf645dc9fa4db9baf49f7b00fb2a5b#58cf645dc9fa4db9baf49f7b00fb2a5b</link>
		<pubDate>Thu, 13 Oct 2011 15:14:27 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/Learning-C/58cf645dc9fa4db9baf49f7b00fb2a5b#58cf645dc9fa4db9baf49f7b00fb2a5b</guid>
		<dc:creator>peoples</dc:creator>
		<slash:comments>5</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/peoples/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Learning C#</title>
		<description><![CDATA[<p>ToString is a method, so it needs to me n.ToString()</p><p>You could even get fancy and pass a culture-specific formatter using n.ToString(CultureInfo.CurrentUICulture)</p><p>&nbsp;</p><p>Herbie</p><p>&nbsp;</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/Learning-C/4a18802a75824ab583399f7b00fcc195#4a18802a75824ab583399f7b00fcc195</link>
		<pubDate>Thu, 13 Oct 2011 15:20:15 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/Learning-C/4a18802a75824ab583399f7b00fcc195#4a18802a75824ab583399f7b00fcc195</guid>
		<dc:creator>Herbie Smith</dc:creator>
		<slash:comments>5</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/Dr Herbie/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Learning C#</title>
		<description><![CDATA[<p>tx</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/Learning-C/a621b0e4fc914bb8beb49f7b00fe1cf8#a621b0e4fc914bb8beb49f7b00fe1cf8</link>
		<pubDate>Thu, 13 Oct 2011 15:25:11 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/Learning-C/a621b0e4fc914bb8beb49f7b00fe1cf8#a621b0e4fc914bb8beb49f7b00fe1cf8</guid>
		<dc:creator>peoples</dc:creator>
		<slash:comments>5</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/peoples/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Learning C#</title>
		<description><![CDATA[<p>The Random object's constructor takes as its parameter a seed value - this object will output numbers via .Next() which are just as random as any other Random object, but two different Random objects with the same seed that have called .Next() the same number of times will generate the same values.</p><p>This is good for example in games played by correspondence, which would allow &quot;random&quot; events to occur on all machines playing the game if the various Random objects had all been seeded with the same number at the start of the game.</p><p>Although this is useful, it's probably not what you want in the function you provided. By creating a new Random object and seeding it with the same value every time you call in, you'll end up with the same number being put in &quot;n&quot; every time you call the function.</p><p>There are two solutions to this. Either use the parameterless constructor (which actually just seeds with the current system time) or store the Random object. When you call .Next() the second time you'll get a randomly different number to the first time you called it and if you store this Random object across calls you'll end up with different values each time you click the button.</p><p>Finally, there are two forms of the Next() function. Next() generates a random number between int.MinValue and int.MaxValue, but Next(m,n) generates a number between m and n (i.e. it can returns either m, m&#43;1, m&#43;2,...n-2, n-1 but not n).</p><p>&nbsp;</p><p>You probably want something like this:</p><p>Random myRand = new Random();</p><div class="post-content"><p>privatevoid button1_Click(object sender, EventArgs e)</p><p>&nbsp;&nbsp;{</p><p>&nbsp; &nbsp; int n = myRand.Next(1,4); // will return 1, 2 or 3.</p><p>&nbsp;&nbsp;&nbsp;&nbsp;this.label1.Text = n.ToString();</p><p>&nbsp; }</p><div>&nbsp;</div></div><form class="spam" action="http://channel9.msdn.com/Forums/TechOff/Learning-C/58cf645dc9fa4db9baf49f7b00fb2a5b/IsSpam" method="POST"></form>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/Learning-C/4676a9d1eff442eb8da79f7b011348e3#4676a9d1eff442eb8da79f7b011348e3</link>
		<pubDate>Thu, 13 Oct 2011 16:42:16 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/Learning-C/4676a9d1eff442eb8da79f7b011348e3#4676a9d1eff442eb8da79f7b011348e3</guid>
		<dc:creator>evildictaitor</dc:creator>
		<slash:comments>5</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/evildictaitor/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Learning C#</title>
		<description><![CDATA[<p>Cheers</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/Learning-C/9672b756e5f84b668b57a0030161712e#9672b756e5f84b668b57a0030161712e</link>
		<pubDate>Sun, 26 Feb 2012 21:26:50 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/Learning-C/9672b756e5f84b668b57a0030161712e#9672b756e5f84b668b57a0030161712e</guid>
		<dc:creator>peoples</dc:creator>
		<slash:comments>5</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/peoples/Discussions/RSS</wfw:commentRss>
	</item>
</channel>
</rss>