O'Reilly logo

Illustrated C# 2008 by Daniel Solis

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

Chapter 5. Methods

The Structure of a Method

Essentially, a method is a block of code with a name. You can execute the code by using the method's name. You can pass data into a method and receive data as output.

As you saw in the previous chapter, a method is a function member of a class. Methods have two major sections, as shown in Figure 5-1—the method header and the method body.

  • The method header specifies the method's characteristics, including the following:

    • Whether the method returns data, and if so, what type

    • The name of the method

    • What types of input can be passed to the method

  • The method body contains the sequence of executable code statements. Execution starts at the first statement in the method body and continues sequentially through the ...

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