Skip to content

Instantly share code, notes, and snippets.

@miguelerm
Created August 23, 2017 14:10
Show Gist options
  • Save miguelerm/59d31ca531385286702674cffc1d58bd to your computer and use it in GitHub Desktop.
Save miguelerm/59d31ca531385286702674cffc1d58bd to your computer and use it in GitHub Desktop.
Explicit private Interface implementation
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