Things that annoy me about C# - interfaces
Interfaces are great, I love 'em. What I don't like is C#'s restriction on the implementation of interfaces. Implementations must be either public (okay), or private using the "interface.method" syntax (okay), but what about protected? I want to be able to do the following, but I can't:
public interface IMyInterface
{
void SomeMethod();
}
public class Class1 : IMyInterface
{
// This causes a compile error
// saying class does not implement interface!!!
protected virtual void SomeMethod()
{
// do stuff
}
}
public class Class2 : Class1
{
protected override void SomeMethod()
{
// do other stuff
}
}
You can do this in VB.NET, why not C#?

0 Comments:
Post a Comment
<< Home