Created
August 23, 2017 14:10
-
-
Save miguelerm/59d31ca531385286702674cffc1d58bd to your computer and use it in GitHub Desktop.
Explicit private Interface implementation
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 Program | |
{ | |
static void Main(string[] args) | |
{ | |
var x = new Test(); | |
var y = x as ITest; | |
y.Foo(); | |
// "x" hasn't a Foo() method but "y" does. | |
} | |
class Test : ITest | |
{ | |
void ITest.Foo() | |
{ | |
Console.WriteLine("Foo!!!"); | |
} | |
} | |
interface ITest | |
{ | |
void Foo(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment