gpt4 book ai didi

c# - 如何获得不同的元素?

转载 作者:太空宇宙 更新时间:2023-11-03 20:15:34 25 4
gpt4 key购买 nike

<分区>

我有一个类如下

class WarningClass
{
public string SqlEyeWarning { get; set; }
public string FileName { get; set; }
}

填充如下

List<WarningClass> lstWarningClass1 = new List<WarningClass>();
lstWarningClass1.Add(new WarningClass { FileName = "a.sql", SqlEyeWarning = "SD001: order mismatch or it should be ON." });
lstWarningClass1.Add(new WarningClass { FileName = "a.sql", SqlEyeWarning = "SD001: order mismatch or it should be ON." });
lstWarningClass1.Add(new WarningClass { FileName = "c.sql", SqlEyeWarning = "SD009: Missing or order mismatch of Grant statement." });

可以看出第一条和第二条记录存在重复条目。

如何获得独特的条目。

最终输出

FileName = "a.sql", SqlEyeWarning = "SD001: order mismatch or it should be ON." 
FileName = "c.sql", SqlEyeWarning = "SD009: Missing or order mismatch of Grant statement."

如果我执行 lstWarningClass1.Distinct(),那将不起作用

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com