C# - TPL2141 logo C# - TPL2141

Overloading is a process where multiple methods with the same name but different signatures are defined. In C#, overloads are resolved at compile-time. Note that the return type of a method is not considered to be a part of a method’s signature (Skeet, n.d.).

Example:

void Foo(int x)
{
    Console.WriteLine("Foo(int x)");
}

void Foo(string x)
{
    Console.WriteLine("Foo(string x)");
}

Calling with

Foo(1);
Foo("String");

will output:

Foo(int x)
Foo(string x)

Live-code example

References

  1. Skeet, J. Overloading. Retrieved from http://csharpindepth.com/Articles/General/Overloading.aspx