using System;
// Declare a generic delegate.
delegate T GenericDelegate(T v);
class GenDelegateDemo {
static int sum(int v) {
int result = 0;
for(int i=v; i>0; i--)
result += i;
return result;
}
static string reflect(string str) {
string result = "";
foreach(char ch in str)
result = ch + result;
return result;
}
public static void Main() {
GenericDelegate intDel = sum;
Console.WriteLine(intDel(3));
GenericDelegate strDel = reflect;
Console.WriteLine(strDel("Hello"));
}
}