I have a doubt in creating constructors
I have a program below
class classname
{
public void classname() \\constructor
{
Console.WriteLine("Hai");
}
public static void Main(string[] args)
{
classname obj=new classname();
}
}
while executing this it gives an error method should not have same name classname
what is reason and what is the solution for this?
Using constructors
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

ArshadRank #2,492 · 564 reputationPosted Jul 29, 2008, 11:00 PM EDT
class classname
{
public void classname() \\constructor
{
Console.WriteLine("Hai");
}
public static void Main(string[] args)
{
classname obj=new classname();
}
Just remove that void from ur Constructor, thanks