标签:style ar color os sp on div bs ad
分配委托(将命名方法分配给其委托)
using System; public class GenericFunc { public static void Main() { // Instantiate delegate to reference UppercaseString method Func<string, string> convertMethod = UppercaseString; string name = "Dakota"; // Use delegate instance to call UppercaseString method Console.WriteLine(convertMethod(name)); } private static string UppercaseString(string inputString) { return inputString.ToUpper(); } }
匿名委托
using System; public class Anonymous { public static void Main() { Func<string, string> convert = delegate(string s) { return s.ToUpper();}; string name = "Dakota"; Console.WriteLine(convert(name)); } }
标签:style ar color os sp on div bs ad
原文地址:http://www.cnblogs.com/LMzj/p/4116550.html