Constructor |Define Constructor -C# Tutorials

We can declare a method that has the same name as the containing class and does not have any return type even void. There are two type of constructor

• Default constructor

• Custom constructor/ parameterized constructor

Static constructor

A static constructor will be executed only once as opposed to the constructor return so far which are instance constructor that is executed whenever an object of that class I created. And use static is a keyword.

Method overloading

Same name but different no of parameter or different parameter data types. These types of method are part of method overloading.


The idea of a property is that it is a method or a pair of methods that are dressed to look like a field as for as any client code is concerned.

There are two property • Get property

• Set property

Get property

It is also known as reading property and use to retrieve the value.

Set property

It is also known as write property and use to initialize the value.

Partial class

The partial keywords allow the class structure or interface to span across multiple files. However is the situation where multiple developers need access to the same class or more lightly is the situation where the code generator of some type is generating a part of the class and these having the class is multiple files can be beneficial. To make the class partial we can use the keyword “partial” in front of the class.


partial class class_name
Body of the class;

Static class

If a class contains nothing but static method and properties the class itself can become static. A static class is functionally the same as creating a class with a private static constructor an instance of the class can never be created.