Skip to main content

Posts

Showing posts from August, 2010

CONSTRUCTORS IN C#

Constructors have the same name as the class, and usually initialize the data members of the new object. Constructors allow the programmer to set default values, limit instantiation, and write code that is flexible and easy to read. A constructor that takes no parameters is called a default constructor. Default constructors are invoked whenever an object is instantiated using the new operator and no arguments are provided to new. If a class is not defined with the constructor then the CLR (Common Language Runtime) will provide an implicit constructor which is called as Default Constructor. A class can have any number of constructors provided they vary with the number of arguments that are passed, which is they should have different signatures. Constructors do not return a value. Constructors can be overloaded. If a class is defined with static and Non-static constructors then the privilege will be given to the Non-static constructors. The following are the access modifiers for const