Possible Duplicate:
Why are private virtual methods illegal in C#?
I have the following code in C#, and Visual Studio is complaining in the Derived class that i cant declare a virtual/ abstract member private.. but i am not .. so does anyone have some ideas? Thanks
public class Base
{
private const string Name= "Name1";
protected virtual string Member1
{
get{
return Name;
}
}
}
public class Derived: Base
{
private const string Name= "Name2";
protected override string Member1
{
get{
return Name;
}
}
}
Unable to reproduce, having fixed the case of “Class” and provided method bodies:
This compiles with no warnings.
If you were trying to declare fields as virtual, you’d get: