Yahoo free web hosting - 188 Methods Chapter 6 returns the value of

188 Methods Chapter 6 returns the value of expression to the caller. When a return statement executes, control returns immediately to the point at which the method was invoked. Notice the syntax that invokes method Squarein Fig. 6.3 we use the method name, followed by the arguments to the method in parentheses. Methods in a class definition are allowed to invoke all other methods in the same class definition by using this syntax (an exception to this is discussed in Chapter 8, Object-Based Programming). We now have seen three ways to call a method a method name by itself (as shown with Square(x)), a reference to an object followed by the dot (.) operator and the method name (such as string1.CompareTo(string2)) and a class name followed by a method name (such as Math.Sqrt( 9.0)). The last syntax is for calling the static methods of a class (discussed in detail in Chapter 8, Object-Based Programming). The application in our next example (Fig. 6.4) uses programmer-defined method Maximum to determine and return the largest of three floating-point values that the user inputs through the program s graphical user interface. Note that in this example, we show all of the code that the Windows Form Designer generates. Throughout the rest of the book, we omit portions of the generated code that are not relevant to our discussions. In such programs, we place a comment that indicates where the Visual Studio .NET generated code appears in the original source file. 1 // Fig. 6.4: MaximumValue.cs 2 // Finding the maximum of three double values. 3 using System; 4 using System.Drawing; 5 using System.Collections; 6 using System.ComponentModel; 7 using System.Windows.Forms; 8 using System.Data; 9 10 namespace MaximumValue 11 { 12 ///

13 /// Summary description for Form1. 14 /// 15 public class MaximumValue : System.Windows.Forms.Form 16 { 17 private System.Windows.Forms.Label firstNumberLabel; 18 private System.Windows.Forms.Label secondNumberLabel; 19 private System.Windows.Forms.Label thirdNumberLabel; 20 private System.Windows.Forms.Label maximumLabel; 21 private System.Windows.Forms.TextBox firstNumberTextBox; 22 private System.Windows.Forms.TextBox secondNumberTextBox; 23 private System.Windows.Forms.TextBox thirdNumberTextBox; 24 private System.Windows.Forms.Button calculateButton; 25 26 /// 27 /// Required designer variable. 28 /// 29 private System.ComponentModel.Container components = null; 30 Fig. 6.4 Programmer-defined Maximum method. (Part 1 of 5.)
If you are in need for chaep and reliable webhost to host your website, our recommendation is http web server services.

Leave a Reply