Created
November 10, 2014 11:48
-
-
Save snippe/5b55b326e337f892d81d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class X | |
{ | |
protected virtual void F() { Console.WriteLine("X.F"); } | |
protected virtual void F2() { Console.WriteLine("X.F2"); } | |
} | |
class Y : X | |
{ | |
sealed protected override void F() { Console.WriteLine("Y.F"); } | |
protected override void F2() { Console.WriteLine("Y.F2"); } | |
} | |
class Z : Y | |
{ | |
// Attempting to override F causes compiler error CS0239. | |
// protected override void F() { Console.WriteLine("C.F"); } | |
// Overriding F2 is allowed. | |
protected override void F2() { Console.WriteLine("Z.F2"); } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A {} | |
sealed class B : A {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment