184 Methods Chapter 6 16 (Shared web hosting) 17 [STAThread] 18
184 Methods Chapter 6 16 17 [STAThread] 18 static void Main() 19 { 20 Application.Run( new SquareInt() ); 21 } 22 23 // Square method definition 24 int Square( int y ) 25 { 26 return y * y; // return square of y 27 28 } // end method Square 29 30 private void calculateButton_Click( object sender, 31 System.EventArgs e ) 32 { 33 outputLabel.Text = “”; 34 35 // loop 10 times 36 for ( int counter = 1; counter <= 10; counter++ ) 37 { 38 // calculate square of counter and store in result 39 int result = Square( counter ); 40 41 // append result to outputLabel 42 outputLabel.Text += "The square of " + counter + 43 " is " + result + "n"; 44 } 45 46 } // end method calculateButton_Click 47 48 } // end of class SquareInt Fig. 6.3 Using programmer-defined method Square. (Part 2 of 2.) Until now, our programs have used methods of class Console to obtain user input from the command prompt. These programs output their results either to the command prompt or in MessageBoxes. Although these are valid ways to receive input from a user and display output, they are fairly limited in their capabilities the command prompt can obtain only one value at a time from the user, and a message dialog can display only one message. It is much more common for programs to read multiple inputs simultaneously
Looking for affordable and reliable webhost to host and run your business application? Then look no more and go to servlet web hosting services.