在List<T>中,Contains, Exists, Any都可以实现判断元素是否存在。
先上结果。性能方面:Contains 优于 Exists 优于 Any
以下为测试代码
public static void Contains_Exists_Any_Test(int num)
{
List<int> list = new List<int>();
int N = num;
for (int i = 0; i < N; i++)
{
list.Add(i);
}
System.Diagnostics.Stopwatch sw = new