linux-packaging-mono/mcs/tests/test-anon-172.cs
Jo Shields 181b81b4a4 Imported Upstream version 3.12.0
Former-commit-id: cf92446697332992ec36726e78eb8703e1f259d7
2015-01-13 10:44:36 +00:00

31 lines
727 B
C#

using System;
using System.Reflection.Emit;
using System.Reflection;
class MainClass
{
public static int Main ()
{
var dynMethod = new DynamicMethod ("Metoda", MethodAttributes.Public | MethodAttributes.Static, CallingConventions.Standard,
null, Type.EmptyTypes, typeof (MainClass), true);
var generator = dynMethod.GetILGenerator ();
generator.Emit (OpCodes.Ldc_I4_7);
GenerateCodeCall (generator, (int a) => {
Console.WriteLine (a);
});
generator.Emit (OpCodes.Ret);
var deleg = (Action)dynMethod.CreateDelegate (typeof (Action));
deleg ();
return 0;
}
static void GenerateCodeCall<T1> (ILGenerator generator, Action<T1> a)
{
generator.Emit (OpCodes.Call, a.Method);
}
}