C# | Default Constructor Last Updated : 23 Jan, 2019 Comments Improve Suggest changes Like Article Like Report If you don't provide a constructor for your class, C# creates one by default that instantiates the object and sets member variables to the default values as listed in the Default Values Table. Constructor without any parameters is called a default constructor. In other words, this type of constructor does not take parameters. The drawback of a default constructor is that every instance of the class will be initialized to the same values and it is not possible to initialize each instance of the class to different values. The default constructor initializes: All numeric fields in the class to zero. All string and object fields to null. Example 1: CSharp // C# Program to illustrate the use // of Default Constructor using System; namespace GFG { class multiplication { int a, b; // default Constructor public multiplication() { a = 10; b = 5; } // Main Method public static void Main() { // an object is created, // constructor is called multiplication obj = new multiplication(); Console.WriteLine(obj.a); Console.WriteLine(obj.b); Console.WriteLine("The result of multiplication is: " +(obj.a * obj.b)); } } } Output: 10 5 The result of multiplication is: 50 Example 2: In this example, the class Person does not have any constructors, in which case, a default constructor is automatically provided and the fields are initialized to their default values. CSharp // C# Program to illustrate the use // of Default Constructor using System; public class Person { public int age; public string name; } // Driver Class class TestPerson { // Main Method static void Main() { // object creation Person pers = new Person(); Console.WriteLine("Name: {0}, Age: {1}", pers.name, pers.age); } } Output: Name: , Age: 0 Note: The output is so because a string is assigned to null by default and integers to 0. Comment More infoAdvertise with us Next Article C# | Default Constructor S Shivam.Pradhan Follow Improve Article Tags : C# CSharp-Basics CSharp-OOP Similar Reads C# Constructors Constructor is a special method of the class which gets automatically invoked whenever an instance of the class is created. Constructors in C# are fundamental components of object-oriented programming. Like methods, It contains the collection of instructions that are executed at the time of Object c 5 min read What is Constructor? A constructor is a special type of method used in object-oriented programming languages to initialize objects. The constructor is called automatically every time when an object is created, allowing the object to set initial values for its attributes or perform other setup tasks.In this article, we w 3 min read Private Constructors in C# Prerequisite: Constructors in C# Private Constructor is a special instance constructor present in C# language. Basically, private constructors are used in class that contains only static members. The private constructor is always declared by using a private keyword. Key PointsIt is the implementatio 3 min read Constructors in Objective-C Constructor is basically a function or method that is called automatically at the time of object creation of a class. constructor method has the same name as that of the class. It is basically used to initialize the data members of the new objects generally. It constructs or creates a new value for 8 min read Constructors in Python In Python, a constructor is a special method that is called automatically when an object is created from a class. Its main role is to initialize the object by setting up its attributes or state. The method __new__ is the constructor that creates a new instance of the class while __init__ is the init 3 min read How to Define the Constructor Outside the Class in C++? A constructor is a special type of member function whose task is to initialize the objects of its class. It has no return type so can't use the return keyword and it is implicitly invoked when the object is created. Constructor is also used to solve the problem of initialization. It is called after 2 min read Type.GetConstructors() Method in C# with Examples Type.GetConstructors() Method is used to get the constructors of the Type object. There are 2 methods in the overload list of this method as follows: Type.GetConstructors() Method This method is used to returns all the public constructors defined for the current Type.Syntax: public System.Reflection 4 min read C# Program to Demonstrate the Static Constructor in Structure A Structure is a well-defined data structure that can hold elements of multiple data types. It is similar to a class because both are user-defined data types and both contain a bunch of different data types. You can also use pre-defined data types. However, sometimes the user might be in need to def 2 min read Invoking an overloaded constructor using this keyword in C# Prerequisite : Constructors in C#C# provides a powerful keyword known as this keyword and this keyword has many usages. Here we use this keyword to call an overloaded constructor from another constructor.Important Points: When you use this keyword to call a constructor, the constructor should belong 3 min read constinit Specifier in C++ 20 The constinit specifier is a new feature that is introduced in C++ 20 that allows us to declare a variable with static storage duration. In this article we will discuss the constinit specifier, its usage, advantages, and limitations. What is constinit Specifier? The constinit specifier is used to ma 3 min read Like