Categories
C# / .NET

Constructor with Parameters (with example)

Constructor are generally used to initialize the variable of the program with values provided in the code itself. However there may be a requirement where the variable need to be initialized with user supplied values. To accomplish this, you can modify the constructor to accept the user supplied values at run time. The following code […]

Categories
C# / .NET

Types of Constructors in C# with Example

There are 2 types of Constructors supported in C#, they are Instance Constructors Static Constructors To understand about constructor, read this article “What is Constructor?” 1. Instance Constructors An instance constructor is called whenever an instance of a class is created. These constructor are used to initialize variables of the class. Consider the following code, […]

Categories
C# / .NET

The need of Constructors in C# Object Oriented Programming

[dropcap background=”yes” color=”#333333″]A[/dropcap] Constructor is a special type of method that is invoked automatically when you create an instance of a class. A constructor is used to initialize the members of the class. The constructor must have the same name as the containing class. Type of Constructors 1. Instance Constructor 2. Static Constructor   Program […]