C#委托的介绍(delegateActionFuncpredicate)
Posted 领域见识决定专业高度
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了C#委托的介绍(delegateActionFuncpredicate)相关的知识,希望对你有一定的参考价值。
static void Main(string[] args) { //Action TestAction<string>(Action, "Hello"); TestAction<int>(Action, 1000); TestAction<string>(p => { Console.WriteLine(p); }, "Lamada"); //Func int result = TestFunc<int, int>((t1, t2) => { return t1 + t2; }, 2, 6); Console.WriteLine(result); //predicate List<int> list = new List<int>() { 1, 2, 3, 4, 5, 6 }; Predicate<int> pre = delegate(int num) { return num > 3; }; list.FindAll(pre).ForEach(n => { Console.WriteLine(n); }); Console.ReadKey(); } static void TestAction<T>(Action<T> action, T p) { action(p); } private static void Action(string s) { Console.WriteLine(s); } private static void Action(int s) { Console.WriteLine(s); } static int TestFunc<T1, T2>(Func<T1, T2, int> func, T1 t1, T2 t2) { return func(t1, t2); }
以上是关于C#委托的介绍(delegateActionFuncpredicate)的主要内容,如果未能解决你的问题,请参考以下文章
C#委托的介绍(delegateActionFuncpredicate)
C#委托的介绍(delegateActionFuncpredicate)
C#委托的介绍(delegateActionFuncpredicate)