123
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace GenericDelegates { public delegate void SomeGenericDelegate<T>(T arg); class Program { static void Main(string[] args) { SomeGenericDelegate<string> strTarget = new SomeGenericDelegate<string>(StringTarget); strTarget("someText"); SomeGenericDelegate<int> intTarget = new SomeGenericDelegate<int>(IntTarget); intTarget(9); Console.ReadLine(); } static void StringTarget(string arg) { Console.WriteLine(arg.ToUpper());} static void IntTarget(int arg) { Console.WriteLine("++arg is {0}:", ++arg); } } } |