andykk
  1. 比较代码 Except方法需要using System.Linq;
private bool CompareList(List<string>? beforeContractConsumerInbounds, List<string>? afterContractConsumerInbounds)
{
    if (beforeContractConsumerInbounds == null || beforeContractConsumerInboundCount == 0 
    || afterContractConsumerInbounds == null || afterContractConsumerInboundCount == 0)
        return false
    List<string> beforeConsumerInbounds = GetHashSortResult(beforeContractConsumerInbounds);
    List<string> afterConsumerInbounds = GetHashSortResult(afterContractConsumerInbounds)
    return beforeConsumerInbounds.Except(afterConsumerInbounds).Any() == false &&
           afterConsumerInbounds.Except(beforeConsumerInbounds).Any() == false;
}
  1. 得到过滤相同值后的结果
protected List<string> GetHashSortResult(List<string> listModel)
{
    HashSet<string> hashString = new HashSet<string>();
    foreach (string item in listModel)
    {
        hashString.Add(item);
    }
    List<string> listResult = new List<string>();
    listResult.AddRange(hashString.ToArray());
    return listResult;
}

分类:

技术点:

相关文章:

  • 2021-08-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
  • 2022-12-23
  • 2022-12-23
  • 2022-01-01
猜你喜欢
  • 2020-06-10
  • 2021-08-11
  • 2021-12-04
  • 2021-11-18
  • 2022-12-23
  • 2021-06-15
相关资源
相似解决方案