Software Development Network>> Visual C#>> wanto use a function as a parameter
Yes its posible through delegates:
Just have a quick look:
private delegate bool FunctionRef(object o); // Should have same signature as function to which it holds reference
private static FunctionRef functionRef = new FunctionRef (CallItUp) ;
private static bool CallItUp(object o)
}
public static void main(){ functionRef (passedObject); }
Delegate is basically a reference to the function or pointer to the function so you can pass it b/w functions and just call them like functions.
A delegate's signature must match to the signature of function which this delegate is going to hold!
I hope this is waht you need!
Best Regards,
wanto use a function as a parameter
Dong Xie
Yes its posible through delegates:
Just have a quick look:
private delegate bool FunctionRef(object o); // Should have same signature as function to which it holds reference
private static FunctionRef functionRef = new FunctionRef (CallItUp) ;
private static bool CallItUp(object o)
}
public static void main()
{
functionRef (passedObject);
}
Delegate is basically a reference to the function or pointer to the function so you can pass it b/w functions and just call them like functions.
A delegate's signature must match to the signature of function which this delegate is going to hold!
I hope this is waht you need!
Best Regards,