class testmath
{
public static int sum(int a, int b)
{
return a + b;
}
public static Boolean prime(int a)
{
int b;
for (b = 2; b < a; b++)
{
if (a % b == 0)
break;
A delegate is a simple class that is used to point to methods with a specific signature, becoming essentially a type-safe function pointer.
If you have a C++ background then thinking of them as function pointers is helpful
A delegate can be seen as a placeholder for a/some method(s).
By defining a delegate, you are saying to the user of your class
"Please feel free to put any method that match this signature here and it will be called each time my delegate is called".
class Program
{
delegate int mathop(int n, int m);//funtion pointer
public static int sum(int a, int b)
{
return a + b;
}
public static int multi(int a, int b)
{
return a * b;
}