Please any one give Explanation [Resolved]

Posted by Gow.Net under C# on 3/6/2012 | Points: 10 | Views : 795 | Status : [Member] | Replies : 4
public class sample
{
public sample()//Constructor
{
A.WriteLine("Its Constructor");
}
}
class Program
{
static void Main(string[] args)
{
Sample objs = new Sample();
}
}

this is my code
i create object for Sample objs = new Sample(); that object objs is Constructor object or Class object

gowthaman8870226416


Responses

Posted by: CGN007 on: 3/6/2012 [Member] Silver | Points: 50

Up
0
Down

Resolved
When you are creating an object using Sample objs = new Sample(),You are creating an instance of the class Sample.
There is nothing called Constructor object in C#.
The constructor of the class will be called automatically,While you are creating an instance of that class.

Please refer more about Constructor in the following link
An Intro to Constructors in C#
http://www.codeproject.com/Articles/7011/An-Intro-to-Constructors-in-C

Gow.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gow.Net on: 3/6/2012 [Member] Starter | Points: 25

Up
0
Down
thank u sir

gowthaman8870226416

Gow.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Akiii on: 3/6/2012 [Member] Bronze | Points: 25

Up
0
Down
@CGN007.......good explanation !

There is nothing like constructor object !

Thanks and Regards
Akiii

Gow.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: CGN007 on: 3/6/2012 [Member] Silver | Points: 25

Up
0
Down
Mark as Answer if its helpful to you,that motivates...

Gow.Net, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response