public static void Main () {
        {
            var d = new TBinaryOperator(Multiply);
            var fp = Marshal.GetFunctionPointerForDelegate(d);

            Console.WriteLine(CallBinaryOperator(fp, 5, 3));
        }

        {
            var d = new TReturnStructArgument(IncrementFields);
            var fp = Marshal.GetFunctionPointerForDelegate(d);

            var a = new TestStruct { I = 1, F = 2.5f };
            var b = CallReturnStructArgument(fp, a);

            Console.WriteLine("i={0} f={1:F4}", b.I, b.F);
        }
    }
    public static void Main()
    {
        {
            var d  = new TBinaryOperator(Multiply);
            var fp = Marshal.GetFunctionPointerForDelegate(d);

            Console.WriteLine(CallBinaryOperator(fp, 5, 3));
        }

        {
            var d  = new TReturnStructArgument(IncrementFields);
            var fp = Marshal.GetFunctionPointerForDelegate(d);

            var a = new TestStruct {
                I = 1, F = 2.5f
            };
            var b = CallReturnStructArgument(fp, a);

            Console.WriteLine("i={0} f={1:F4}", b.I, b.F);
        }
    }
示例#3
0
 public static extern int CallBinaryOperator (TBinaryOperator op, int a, int b);
 public C1(TBinaryOperator arg)
 {
     this.arg = arg;
 }
示例#5
0
 public static extern int CallBinaryOperator(TBinaryOperator op, int a, int b);