我不知道为什么,但是visual studio的编译器让我让这个函数变得静态.
我有很多字符串列表
List<string> universe = new List<string>();
List<string> foo1 = new List<string>();
List<string> foo2 = new List<string>();
List<string> foo3 = new List<string>();
.
.
.
List<string> fooN = new List<string>();
Run Code Online (Sandbox Code Playgroud)
一些列表可能是空的而其他列表有数据,我想在有数据的人之间交叉,所以我做了这个函数:
public List<string> IntersectIgnoreEmpty(this List<string> list, List<string> other)
{
if (other.Any())
return list.Intersect(other).ToList();
return list;
}
Run Code Online (Sandbox Code Playgroud)
它给了我错误,直到我把它变成静态.我不知道为什么.
| 归档时间: |
|
| 查看次数: |
60 次 |
| 最近记录: |