O'Reilly logo

Visual C#® 2012: How to Program, Fifth Edition by Harvey Deitel, Paul Deitel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

7.5. Notes on Declaring and Using Methods

You’ve seen three ways to call a method:

1. Using a method name by itself to call a method of the same class—such as Maximum(number1, number2, number3) in line 18 of Fig. 7.3.

2. Using a variable that contains a reference to an object, followed by the member access (.) operator and the method name to call a non-static method of the referenced object—such as the method call in line 13 of Fig. 6.10, myGradeBook.DisplayMessage(), which calls a method of class GradeBook from the Main method of GradeBookTest.

3. Using the class name and the member access (.) operator to call a static method of a class—such as Convert.ToDouble(Console.ReadLine()) in lines 13–15 of Fig. 7.3 or Math.Sqrt(900.0) in Section 7.3 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required