Created
September 10, 2012 18:56
-
-
Save davybrion/3692965 to your computer and use it in GitHub Desktop.
code snippets for "Is There A Good Reason To Hide Inherited Members?" post
This file contains hidden or 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
public class MyClass | |
{ | |
public void DoSomething() | |
{ | |
Console.WriteLine("i'm doing something important"); | |
} | |
} |
This file contains hidden or 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
public class MyDerivedClass : MyClass | |
{ | |
public void DoSomething() | |
{ | |
base.DoSomething(); | |
Console.WriteLine("(i'm just better at it)"); | |
} | |
} |
This file contains hidden or 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
new public void DoSomething() | |
{ | |
base.DoSomething(); | |
Console.WriteLine("(i'm just better at it)"); | |
} |
This file contains hidden or 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
new MyClass().DoSomething(); | |
new MyDerivedClass().DoSomething(); |
This file contains hidden or 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
static void DoIt(MyClass subject) | |
{ | |
subject.DoSomething(); | |
} | |
static void Main(string[] args) | |
{ | |
DoIt(new MyClass()); | |
DoIt(new MyDerivedClass()); | |
Console.ReadLine(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment