switch
Statement (Cont.)
Random
function initializes the random number generator.
Next
function returns an integer within a range.
ToString
function returns a string representation of a number.
int.Parse
method converts the string representation of a number.
private void Start_Click( object sender, EventArgs e ) { int firstNum, secondNum; Random rnd = new Random( ); firstNum = rnd.Next( 0, 100 ); secondNum = rnd.Next( 0, 100 ); x.Text = firstNum.ToString( ); y.Text = secondNum.ToString( ); } |
private void OK_Click( object sender, EventArgs e ) { switch ( int.Parse(z.Text) == int.Parse(x.Text) + int.Parse(y.Text) ) { case true: display.Text = "Correct"; image.Visible = true; break; default: display.Text = "Incorrect"; image.Visible = false; break; } } |
System.Object
class is the ultimate base class of all classes in the .NET Framework; it is the root of the type hierarchy.
System.EventArgs
is the base class for classes containing event data.
private void Next_Click( object sender, EventArgs e ) { z.Text = ""; display.Text = ""; Start_Click( sender, e ); } |