why can not create instance from any class out side of constructor?
Posted
by Phsika
on Stack Overflow
See other posts from Stack Overflow
or by Phsika
Published on 2010-05-28T14:07:06Z
Indexed on
2010/05/28
14:11 UTC
Read the original article
Hit count: 125
why i generate instance outside of class. i give inheritance snifC to sinifD i need to create instance sinifC sinifc= new sinifC() in SinifD out side of constructor?
public class sinifC
{
public void method3()
{
Console.WriteLine("Deneme3");
}
}
public class sinifD : sinifC
{
void method4()
{
Console.WriteLine("Deneme4");
}
public sinifD()
{
sinifC sinifc = new sinifC();
sinifc.method3();
}
}
i want to make it below:
public class sinifC
{
public void method3()
{
Console.WriteLine("Deneme3");
}
}
public class sinifD : sinifC
{
void method4()
{
Console.WriteLine("Deneme4");
}
sinifC sinifc = new sinifC();
sinifc.method3();
}
Error: Invalid token '(' in class, struct, or interface member declaration
© Stack Overflow or respective owner