M
^MisterJingo^
I've been reading up on interfaces, one example I came across showed
that you can hide a method implemented from an interface from the class
which implements it. To use it, you must cast to the interface type
e.g.:
interface IFoo
{
void display();
}
class Blah : IFoo
{
void IFoo.display()
{
System.Console.WriteLine("hello");
}
}
class MainApp
{
public static void Main()
{
Blah myBlah = new Blah();
myBlah.display(); //error
((IFoo)myBlah).display(); //works
}
}
In what circumstances would you ever want to do this? The place I found
this didn't explain why this would ever be done.
Sorry if these questions are missing the obvious .
Chris
that you can hide a method implemented from an interface from the class
which implements it. To use it, you must cast to the interface type
e.g.:
interface IFoo
{
void display();
}
class Blah : IFoo
{
void IFoo.display()
{
System.Console.WriteLine("hello");
}
}
class MainApp
{
public static void Main()
{
Blah myBlah = new Blah();
myBlah.display(); //error
((IFoo)myBlah).display(); //works
}
}
In what circumstances would you ever want to do this? The place I found
this didn't explain why this would ever be done.
Sorry if these questions are missing the obvious .
Chris