1.3.3 Method Signatures

A Method Declaration Tells C# How the Method Is Identified

Consider:

C#
public void DisplayRoster()
{
}

At this stage, notice three important parts:

Plain text
public        → access
void          → return type
DisplayRoster → method name
()

The parentheses are part of the method declaration.

Parameters are taught later, so current examples use an empty parameter list.

The Name Communicates the Behavior

A method name such as:

Plain text
DisplayRoster

should help a reader understand what the method is intended to do.

void Means No Value Is Returned

For:

C#
public void DisplayRoster()

void means the method does not return a value to its caller.

Returning values is taught later in PC1.

Access Modifiers Still Apply

A method can have an access modifier such as public or private.

The current class design controls whether code outside the class should be able to call it directly.

Method Calls Use the Name and Parentheses

If team1 refers to a Team object:

C#
team1.DisplayRoster();

the call identifies the object and invokes the method.

This connects:

Plain text
method definition
      ↓
method call

The next activities focus on what a method is and how a void method behaves.