Func<TResult> Func<T,TResult> Func<T1,T2,TResult> Func<T1,T2,T3,TResult> Func<T1,T2,T3,T4,TResult>
private delegate string Say();
public static string SayHello()
{
return "Hello";
}
static void Main(string[] args)
{
Say say = SayHello;
Console.WriteLine(say());
Console.ReadKey();
}
public static string SayHello()
{
return "Hello";
}
static void Main(string[] args)
{
Func<string> say = SayHello;
Console.WriteLine(say());
Console.ReadKey();
}
public static string SayHello(string str)
{
return str + str;
}
static void Main(string[] args)
{
Func<string, string> say = SayHello;
string str = say("abc");
Console.WriteLine(str); //输出abcabc
Console.ReadKey();
}
Action Action<T> Action<T1,T2> Action<T1,T2,T3> Action<T1,T2,T3,T4>
private delegate string Say();
public static void SayHello(string str)
{
Console.WriteLine(str);
}
static void Main(string[] args)
{
Action<string> say = SayHello;
say("abc");
Console.ReadKey();
}
Func<string, string> say = m => m + m;
Console.WriteLine(say("abc")); //输出abcabc
namespace ConsoleApplication2
{
static class Extend
{
public static TSource First2<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
{
//.Net本身的源代码好多异常情况处理,好多设计模式,我也不懂,只提取逻辑
foreach (TSource item in source)
{
if (predicate(item))
{
return (item);
}
}
throw new Exception("不存在满足条件的第一个元素!");
}
}
class Program
{
static void Main(string[] args)
{
List<int> ListInt = new List<int>(){ 1, 2, 3, 4, 5 };
int k = ListInt.First2(m => m > 4); //输出5
Console.WriteLine(k);
Console.ReadKey();
}
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有