主要是关于集合:列表

列表

删除

Remove(object) 删除对象
RemoveAt(int) 删除对象,比较快,因为是索引的,找地址的
RemoveRange(int index,int count) 删除连续的部分

查找

indexof和lastindexof 入参是T,出参是索引
findindex换findlastindex xxx.findindex(r=>r.name==“你好”),可以根据某个条件查找索引
find和findLast和FIndAll 和上面的差不多,但是返回的的是T

排序

xxx.Sort((r1, r2) => r2.Wins.CompareTo(r1.Wins));

Reverse 倒叙

集合

以下四个都是比较常见的方法,需要注意的是,这几个方法都是void,即直接影响调用的对象本身

UnionWith 并集/加法 合并两个集合的元素
IntersectWith 交际 提出去共有的部分 C
ExceptWith 减法 被减数独有的部分,A-B 1,2,3
SymmetricExceptWith 除去共有的 1,2,3,4,5,6

UnionWith/并集

data1.UnionWith(data2);
DisplaySet(data1);

///{ 1 2 3 7 4 5 6 }

IntersectWith/交集

data1.IntersectWith(data2);
DisplaySet(data1);

///{ 7 }

ExceptWith/减法

data1.ExceptWith(data2);
DisplaySet(data1);
//1237-4567
///{ 1 2 3 }

data2.ExceptWith(data1);
DisplaySet(data2);
//4567-1237
///{ 4 5 6 }

SymmetricExceptWith/合并各自独有的

dd.SymmetricExceptWith(data2);
DisplaySet(dd);

///{ 1 2 3 4 5 6 }