Exemple #1
0
        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);
        }
Exemple #2
0
        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);
        }
 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.");
     }
 }
        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);
        }
Exemple #5
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);
	}
Exemple #6
0
	public static extern int mono_test_marshal_delegate2 (SimpleDelegate2 d);
Exemple #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));
    }
Exemple #8
0
 public static extern int mono_test_marshal_delegate2(SimpleDelegate2 d);