|
.Net Tricks |
2004-01-26 |
|
After playing around with gpcp recently, I decided to read John Gough's Compiling for the .NET Common Language Runtime again. I found something interesting in there that I missed the first time around: interfaces can implement static methods and fields. This appears to be another interesting feature that is not supported by mainstream msft languages, but is available. The IL looks like:
.class public interface InterfaceWithStatic {
.method public static void StaticMethod() cil managed {
ldstr "hello from static method on interface"
call void [mscorlib]System.Console::WriteLine(string)
ret
}
}
So this makes it on to my list of .NET party tricks, along with global methods and throwing non-exception types. |
|