I was trying to implement an Interface by a class but i wanted to have static methods.
But C# doesn't allow static methods in interface.
After a little search,I got "why We can't have static methods in Interfaces".
suppose i have an interface,
interface IDemo
{
static void add();
}
Now we implement it:
class MyClass:IDemo
{
static void add()
{
Console.WriteLine("Added");
}
}
Pretty cool na.
But it won't compile.
because what if
IDemo.add();
To avoid this ambiguity,
Static Methods are not allowed in Interfaces .
Note::
Although not implemented in C# the CLR does support static methods on interfaces. The drawback is that from C# you'd have to invoke them using reflection.