[泛型委托]-C# 三种泛型委托的使用
2014-11-14 23:48
323 查看
C# 三种泛型委托的使用Demo
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Demo { class Program { static void Main(string[] args) { Action<string> test = delegate(string s) { Console.WriteLine(s); }; test("Action delegate Test"); Predicate<string> predicateTest = delegate(string s) { return s == "Hello"; }; Console.WriteLine(predicateTest("Hello")); Func<string, string> func = delegate(string s) { return s + " Func"; }; string result = func("Hello"); Console.WriteLine(result); Console.ReadKey(); } } }作为个人温习,请勿喷!
相关文章推荐
- 编写高质量代码改善C#程序的157个建议[为泛型指定初始值、使用委托声明、使用Lambda替代方法和匿名方法]
- C#中使用委托、接口、匿名方法、泛型委托实现加减乘除算法
- 编写高质量代码改善C#程序的157个建议[为泛型指定初始值、使用委托声明、使用Lambda替代方法和匿名方法]
- 深入解析C#编程中泛型委托的使用
- C#中使用委托、接口、匿名方法、泛型委托实现加减乘除算法
- C#中使用委托、接口、匿名方法、泛型委托实现加减乘除算法
- c#打包文件解压缩 C#中使用委托、接口、匿名方法、泛型委托实现加减乘除算法 一个简单例子理解C#的协变和逆变 对于过长字符串的大小比对
- 实验分析C#中三种计时器使用异同点
- 在C#的事件、多播中使用委托
- 使用C#创建webservice及三种调用方式
- 【C#食谱】【面食】菜单1: 何时何地使用泛型
- (原創) 我的Design Pattern之旅[7]:使用泛型改進Adapter Pattern (OO) (Design Pattern) (C/C++) (template) (.NET) (C#) (C++/CLI) (VB)
- C# 委托(Delegate)使用
- C#中使用委托
- C#强化系列文章三:实验分析C#中三种计时器使用异同点
- 实验分析C#中三种计时器使用异同点
- 何时使用委托而不使用接口(C# 编程指南)
- 使用C#创建webservice及三种调用方式
- C#泛型技巧:使用 C# 2.0 泛型来完成单例模式的重用
- 使用C#创建webservice及三种调用方式