Types of constructor C# dot net ,instance constructors ,Non instance constructors
Types of constructor C# dot net ,instance constructors ,Non instance constructors
Types of constructor:
a)instance constructors
1)Default constructor:-
- User defined default constructor
- System defined default constructor
2)Parameterized constructor
3)Copy constructor
4)Private constructor
b )Non instance constructors
1)Static constructor
User defined default constructor:-
- This constructor is created by the programmer with in the class.
- This is the parameter less constructor.
- In general this constructor is used to initialize the required data into the data fields.
- A class can contain only one default constructor.
- A class can contain only one default constructor.
- If class can contain more than one default constructor it raises a compilation error due to ambiguity.
System defined default constructor:
- When their is no constructor available with in the class run time will create its own constructor and will store the default values in to the data fields.
- This constructor created by the run time is known as system defined default constructor.
- When an object to the class is created first system will search for a constructor with in the class,if there is no constructor available with in the class system will crate its own constructor and will assign in to the Data Fields.
0 comments:
Post a Comment