********************************************************************************************
Today, the teacher out of a problem, asked to use C # 's while statement to write the following code
The user is constantly asked to enter an integer that displays the maximum value of the number that was just entered when the user enters end.
I wrote a, I feel there is no problem, but the input end is always error, solve, thank you
1 intmax=0;2 strings ="";3 while(s!="End")4 {5Console.WriteLine ("Please enter a number");6s =console.readline ();7 intNumber =Convert.ToInt32 (s);8 9 if(Number >max)Ten { OneMax =Number ; A } - } - theConsole.WriteLine (max);
The following again wrote a There is no problem, stay for the students just learn reference.
1 intMax =0;2 while(true)3 {4Console.WriteLine ("Please enter a number (end Please enter end):");5 strings =console.readline ();6 if(s = ="End")7 Break;8 intNumber =Convert.ToInt32 (s); 9 if(Number >max)Ten { OneMax =Number ; A } - - the } - -Console.WriteLine ("The maximum value you entered earlier is {0}", max); -Console.readkey ();
Little white to help you, great gods. C#while Cycle Usage