Suppose I have the following ILAsm code:
.class public interface abstract ITest { .field public static int32 counter .method public static void StaticMethod(string str) { ldarg.0 call void [mscorlib]System.Console::WriteLine(string) ret } .method public virtual abstract void InstMethod(string) { } }
Is it possible to define a class in C # that implements this ITest interface?
I can implement this interface in ILAsm:
.class public TestImpl extends [mscorlib]System.Object implements ITest { .method public virtual void InstMethod(string str) { ldarg.1 call void ITest::StaticMethod(string) ret } .method public specialname rtspecialname instance void .ctor() { ldarg.0 call instance void .base::.ctor() ret } }
and successfully use the implemented class in C # code:
var testImpl = new TestImpl(); testImpl.InstMethod("I'm static!");
But what about implementing this interface in C #?
user2341923
source share