Instantiating Interfaces in C#?

Posted by RealityDysfunction on Programmers See other posts from Programmers or by RealityDysfunction
Published on 2012-10-06T23:54:03Z Indexed on 2012/10/07 3:51 UTC
Read the original article Hit count: 183

Filed under:
|

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

© Programmers or respective owner

Related posts about c#

Related posts about interfaces