<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Samet Kilictas&#039;s Blog &#187; Random</title>
	<atom:link href="http://samet.kilictas.com/tag/random/feed/" rel="self" type="application/rss+xml" />
	<link>http://samet.kilictas.com</link>
	<description>J2E, PHP, Linux, PL/SQL and other random rants</description>
	<lastBuildDate>Sun, 06 Nov 2011 04:36:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Tutorial #2 &#8211; Basic Guess Game in C#</title>
		<link>http://samet.kilictas.com/basic-guess-game-in-c-sharp/</link>
		<comments>http://samet.kilictas.com/basic-guess-game-in-c-sharp/#comments</comments>
		<pubDate>Mon, 10 Nov 2008 18:14:03 +0000</pubDate>
		<dc:creator>Samet Kilictas</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Enter Key Handling]]></category>
		<category><![CDATA[MessageBox.Show]]></category>
		<category><![CDATA[Random]]></category>
		<category><![CDATA[Random Function]]></category>
		<category><![CDATA[Textfield]]></category>

		<guid isPermaLink="false">http://samet.kilictas.com/?p=83</guid>
		<description><![CDATA[Here is my new tutorial for you about C#. In this tutorial i am going to make a little game about guessing result of some number summation, multiplation, division and addition. And i am going to focus on handling the enter keypress event for textfield. Here as you see from the screenshot of the main [...]]]></description>
			<content:encoded><![CDATA[<p>Here is my new tutorial for you about C#. In this tutorial i am going to make a little game about guessing result of some number summation, multiplation, division and addition. And i am going to focus on handling the enter keypress event for textfield.</p>
<p><a href="http://samet.kilictas.com/wp-content/uploads/2008/11/guessgame.jpg"><img class="alignnone size-medium wp-image-84" title="Game Window" src="http://samet.kilictas.com/wp-content/uploads/2008/11/guessgame-300x269.jpg" alt="" width="300" height="269" /></a></p>
<p>Here as you see from the screenshot of the main window a user should guess the result of this operation. Textbox1 equals the random number &#8220;96&#8243;, textbox2 equals the random number &#8220;73&#8243; and there is an randomly operator which is &#8220;-&#8221; . User should guess this result and should write down the guess into the textbox3 field. When user press enter button textbox3 handles this event.</p>
<pre class="brush: csharp">
private void textBox3_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)13) //Char 13 handles the enter key
{
Console.WriteLine(total);  //Here i can check the result from console for testing purposes
if (total.ToString() == textBox3.Text)
{
StringBuilder dogru_str = new StringBuilder();
dogru_str.Append(textBox1.Text);
dogru_str.Append(&quot; &quot; + label1.Text + &quot; &quot;);
dogru_str.Append(textBox2.Text + &quot; = &quot;);
dogru_str.Append(total + &quot;\n&quot;);
dogru_str.Append(&quot;Your answer was correct...&quot;);
MessageBox.Show(dogru_str.ToString(), &quot;Result&quot;, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);</pre>
<p><span id="more-83"></span></p>
<p>Here dogru_str keeps the new string. Then  i am able to send this paramater to MessageBox.Show</p>
<pre class="brush: csharp">
wins += 1; //Here i can show that how many times user wins
label4.Text = wins.ToString();
textBox3.ReadOnly = true;
}
else
{
StringBuilder yanlis_str = new StringBuilder();
yanlis_str.Append(textBox1.Text);
yanlis_str.Append(&quot; &quot; + label1.Text + &quot; &quot;);
yanlis_str.Append(textBox2.Text + &quot; = &quot;);
yanlis_str.Append(total + &quot;\n&quot;);
yanlis_str.Append(&quot;Your answer was wrong.!!&quot;);
MessageBox.Show(yanlis_str.ToString(), &quot;Result&quot;, MessageBoxButtons.OK, MessageBoxIcon.Error);
loses += 1;
label5.Text = loses.ToString();
textBox3.ReadOnly = true;
}
}
}  </pre>
<p>After pressing enter button it determines if it is wrong answer or not. Then user should press replay button the replay the game.</p>
<p>&#8230;</p>
<a href='http://twitter.com/share?url=http%3A%2F%2Fsamet.kilictas.com%2F%3Fp%3D83&count=vertical&related=&text=Tutorial%20%232%20-%20Basic%20Guess%20Game%20in%20C%23' class='twitter-share-button' data-text='Tutorial #2 - Basic Guess Game in C#' data-url='http://samet.kilictas.com/?p=83' data-counturl='http://samet.kilictas.com/basic-guess-game-in-c-sharp/' data-count='vertical' data-via='sametkilictas'>Tweet</a>]]></content:encoded>
			<wfw:commentRss>http://samet.kilictas.com/basic-guess-game-in-c-sharp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

