Created
September 1, 2012 16:19
-
-
Save anonymous/3579198 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
using System; | |
namespace ConsoleApplication1 | |
{ | |
interface ITest | |
{ | |
void Method(); | |
} | |
class Parent : ITest | |
{ | |
void ITest.Method() | |
{ | |
Console.WriteLine("Parent"); | |
} | |
} | |
class Child : Parent, ITest | |
{ | |
void ITest.Method() | |
{ | |
Console.WriteLine("Child"); | |
} | |
} | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var c = new Child(); | |
Parent p = c; | |
object o = p; | |
((ITest)c).Method(); // Child | |
((ITest)p).Method(); // Child | |
((ITest)o).Method(); // Child | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment