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