Showing posts with label private constructor. Show all posts
Showing posts with label private constructor. Show all posts

Saturday, 7 January 2012

Article 2:-Constructor in more Detail


For Asp.net Training with C# Click Here

Written By:-Isha Malhotra
Email:-malhotra.isha3388@gmail.com


In the previous article Click here for previous article we have learnt the class and constructor in the basic level. In this article we will learn more about the constructors and will study constructor in detail.

Ques:-1 what is the difference between method and constructors?
Ans:- a) Constructor doesn’t have any return type not even void but every method must contain the return type and if any method doesn’t return anything then it will return void.
b) Constructor called automatically but method is called by the object or with the class name
Note:-in case of static method we call method with the name of class.
c) Constructer will be called only once but we can call the method many times.

Ques 2:-What is the type of constructors?
Ans:- there are two types of constructor and these are following
a)      Static Constructor(also known as class constructor)
b)      Non static Constructor(also known as instance constructor)