Method Overloading in Classes

Let's learn about method overloading.

What is method overloading?

Overloading a method occurs when methods have the same name but different signatures. The compiler knows which method to use based on what’s called.

Syntax

class ExampleOverloadMethod 
{ 
  public static void DisplayMe()
  {
    Console.WriteLine( "Result: Nothing to Display" ); 
  }

  public static void DisplayMe(string theString)
  { 
    Console.WriteLine( $"The string {theString} was called");
  }
}

Example

Get hands-on with 1200+ tech skills courses.