- A constructor is a special method whose task is to initialize the object of its class.
- It is special because its name is the same as the class name.
- They do not have return types, not even void and therefore they cannot return values.
- They cannot be inherited, though a derived class can call the base class constructor.
- Constructor is invoked whenever an object of its associated class is created.
- Note: There is always atleast one constructor in every class. If you do not write a constructor, C# automatically provides one for you, this is called default constructor. Eg: class A, default constructor is A().
This blog is for .NET and related web technology, where you will find some really good and time saving answers which can help you to make your fundaas clear.
Tuesday, March 20, 2012
Constructor in C#
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment