delegate declaration in c#
public delegate int PerformCalculation(int x, int y);
delegate declaration in c#
public delegate int PerformCalculation(int x, int y);
c# delegate
// Declare a delegate type
public delegate double MyDelegateType(double x);
// Define some consummer that uses functions of the delegate type
public double Consummer(double x, MyDelegateType f){
return f(x);
}
//...
// Define a function meant to be passed to the consummer
// The only requirement is that it matches the signature of the delegate
public double MyFunctionMethod(double x){
// Can add more complicated logic here
return x;
}
// In practice now
public void Client(){
double result = Consummer(1.234, x => x * 456.1234);
double secondResult = Consummer(2.345, MyFunctionMethod);
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us