コード例 #1
0
ファイル: DelegateTest.cs プロジェクト: Tob1112/seungbeomi
        public static void Main(string[] args)
        {
            AType atype = new AType();

             SimpleDelegate1 s1 = new SimpleDelegate1(atype.F1);
             SimpleDelegate2 s2 = new SimpleDelegate2(atype.F2);

             s1();
             s2(1234);
        }
コード例 #2
0
ファイル: DelegateTest.cs プロジェクト: Tob1112/seungbeomi
        public static void Main(string[] args)
        {
            AType atype = new AType();

            SimpleDelegate1 s1 = new SimpleDelegate1(atype.F1);
            SimpleDelegate2 s2 = new SimpleDelegate2(atype.F2);

            s1();
            s2(1234);
        }
コード例 #3
0
 public static void Caller(SimpleDelegate2 function)
 {
     if (function != null)
     {
         function("Hello from the delegate!");
         Console.WriteLine($"Method represented by this delegate: {function.Method}");
     }
     else
     {
         Console.WriteLine("The delegate function was null.");
     }
 }
コード例 #4
0
        static void Main(string[] args)
        {
            // Instantiation.
            // Create an instance similar to class instantiation and pass in the function
            // that you want that delegate to reference.
            SimpleDelegate  simpleDelegate = new SimpleDelegate(MyFunc);
            SimpleDelegate2 messageFunc    = new SimpleDelegate2(Message);

            // Invocation of the delegate;
            simpleDelegate();

            // Invocation of the function that takes delegate as an argument.
            Caller(messageFunc);

            // Create new object of type SampleTest that will utilize its
            // internal delegate declarations.
            SampleTest myObj = new SampleTest();

            // Pass the Messenger function from the Program class
            // as a parameter for the delegate parameter used in the Process method.
            myObj.Process(Messenger);
        }
コード例 #5
0
ファイル: pinvoke3.cs プロジェクト: GirlD/mono
	/* Test structures as arguments and return values of delegates */
	public static int test_0_marshal_struct_delegate () {
		SimpleDelegate2 d = new SimpleDelegate2 (delegate_test_struct);

		return mono_test_marshal_delegate2 (d);
	}
コード例 #6
0
ファイル: pinvoke3.cs プロジェクト: GirlD/mono
	public static extern int mono_test_marshal_delegate2 (SimpleDelegate2 d);
コード例 #7
0
    /* Test structures as arguments and return values of delegates */
    public static int test_0_marshal_struct_delegate()
    {
        SimpleDelegate2 d = new SimpleDelegate2(delegate_test_struct);

        return(mono_test_marshal_delegate2(d));
    }
コード例 #8
0
 public static extern int mono_test_marshal_delegate2(SimpleDelegate2 d);