50 likes | 310 Views
CS 3260. C# Delegates. C++ Function Pointers C# Method References Groundwork for Lambda Functions. Overview. Reference Type Type Declaration delegate void MyDelegate ( int ival , double dval ); Variable Declaration MyDelegate mdel = new MyDelegate ( MyMethod ); Method Declaration
E N D
CS 3260 C# Delegates
C++ Function Pointers C# Method References Groundwork for Lambda Functions Overview
Reference Type • Type Declaration • delegate void MyDelegate(intival, double dval); • Variable Declaration • MyDelegatemdel = new MyDelegate(MyMethod); • Method Declaration • void MyMethod(intiv,doubledv){ … } • Method Call via the Delegate • mdel(100,5.5); • Type-Safe • Can have generic parameters C# Delegates
delegate T Gdelegate<T,K>(T tval,Kkval); Func<> Action<> Generic Delegate