A
avnrao
Hi,
I am curious about how to write C# class with this requirement : I want to
make one of the methods of the class to be non overridable in derived
classes.
I cannot use sealed because sealed keyword on a method should also have
override keyword. My class here is the master class.
Consider a class Master with 2 methods
public class Master
{
public virtual string Method1()
{
}
public string Method2()
{
}
}
public class Child : Master
{
public override string Method1()
{
}
}
how to make Method2 as non-overridable and Method1 as overridable by Child
class?
I am curious about how to write C# class with this requirement : I want to
make one of the methods of the class to be non overridable in derived
classes.
I cannot use sealed because sealed keyword on a method should also have
override keyword. My class here is the master class.
Consider a class Master with 2 methods
public class Master
{
public virtual string Method1()
{
}
public string Method2()
{
}
}
public class Child : Master
{
public override string Method1()
{
}
}
how to make Method2 as non-overridable and Method1 as overridable by Child
class?