我用了一个结构

public struct stuff
{
    public int ID;
    public int quan;
}

List<stuff> stuff = new List<stuff>();
我如何检查列表中是否已有东西“ID = 1”?

最佳答案

您可以非常轻松地使用LINQ

bool res = stuff.Any(c => c.ID == 1);

09-28 08:07
查看更多