C# 代码片段

为Linq的Where增加重载以支持多个参数

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
30
31
32
33
34
35
36
37
38
//定义扩展
public static class EX
{
public static List<Tsource> Where<Tsource,T2>(this IEnumerable<Tsource> items,Func<Tsource, T2, bool> func, T2 temp)
{
List<Tsource> list = new List<Tsource>();
foreach (Tsource item in items)
{
if (func(item, temp))
{
list.Add(item);
}
}
return list;
}
}

//使用扩展
class Program
{
static void Main(string[] args)
{
List<string> stringItems = new List<string>{ "张三","李四","王五","马六","王二麻子","钱掌柜","葫芦棍子","屎蛋" };

//筛选名字长度
int limitLength = 2;
//定义筛选器
Func<string, int, bool> func = (origin, temp) => origin.Length > temp;
//调用扩展
List<string> res = stringItems.MyWhere(func,limitLength);
foreach (var item in res)
{
Console.WriteLine("名字长度大于2的项目:" + item);
}

Console.Read();
}
}

操作系统中线程的数据结构包括的主要内容

  • Thread内核数据结构,主要OSId()线程的ID,Context上下文(存放了CPU寄存器相关的变量)

应用程序域

Application Domain 用于个里再同一个计算机上运行的不同程序


C# 代码片段
https://jacksiongt.github.io/2020/01/11/CSharp/
作者
Jacksion
发布于
2020年1月11日
许可协议