VOOZH about

URL: https://www.geeksforgeeks.org/c-sharp/constructor-overloading-c-sharp/

⇱ Constructor Overloading in C# - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Constructor Overloading in C#

Last Updated : 13 Sep, 2025

Constructor overloading in C# means writing more than one constructor in the same class, but with different parameters. It lets you create objects in different ways, depending on what information you have when making the object.

  • You can overload a constructor by changing the number of parameters or their types.
  • Each constructor must look different so the compiler knows which one to call.
  • This makes object creation more flexible and easier to use.

We can achieve Constructor overloading in many different ways.

1. Overloading by Changing Number of Parameters

A class may have constructors that accept different numbers of parameters. This allows objects to be initialized with varying levels of detail.


Output
Name: Unknown, Age: 0
Name: John, Age: 18
Name: Alice, Age: 22

2. Overloading by Changing Data Types

Constructors can also differ by the type of parameters. For example, one constructor may accept integers while another accepts doubles.


Output
Result: 30
Result: 10

3. Overloading by Changing Order of Parameters

Even if the types are the same, changing the order of parameters makes constructors distinct.


Output
Name: Alice, Id: 101
Name: Bob, Id: 102

Note

  • A static constructor cannot be overloaded because it always has no parameters.
  • A private constructor can be overloaded, but it can only be used inside the same class since private members are not accessible from outside the class.
Comment

Explore