Instantiating Interfaces in C#?
- by RealityDysfunction
I am reading/learning about interfaces in C# at the moment, and thus far I managed to understand how it differs from an abstract class. In the book I am reading the author explains that interfaces are the ultimate abstract class and that it simply sets the standard of certain methods the inheriting class will have, but then provides the following example...
static void Main(string[] args)
{
...
Circle c = new Circle("Lisa");
IPointy itPt = null;
try
{
itPt = (IPointy)c;
Console.WriteLine.(itPt.Points);
}
catch (InvalidCastException e)
{
Console.WriteLine(e.Message);
}
...
}
The line that absolutely throws me off is the "IPointy itfPt=null;" did he just declare an interface??? I thought interfaces are abstract and can only be inherited? What kind of sorcery is going on here?
Thanks for any help,
I