首页 > 解决方案 > c#删除自定义列表的重复项

问题描述

你好,我有一串像

BRC CORP---BRC SME,BRC SME---BRC CORP,Confirmation of Customer Contact,Confirmation of Suitability Check,Consent,Driver's License---National Id Card,National Id Card---Driver's License,Residence certificate

现在我需要将其转换为下面的列表。

using System.Collections.Generic;
using System.Linq;

try
{
    string  mondantory_docs=Batch.Properties.Get("MissingDocCheck");
    List<string> result = mondantory_docs.Split(',').ToList();

}
catch
{
}

但是我有一个问题,我找不到方法。BRC CORP---BRC SME 并且BRC SME---BRC CORP通常是相同的。所以我需要从列表中删除其中一个。结果我想在下面。

BRC CORP---BRC SME,Confirmation of Customer Contact,Confirmation of Suitability Check,Consent,Driver's License---National Id Card,Residence certificate 

如何从列表中删除这种重复项

谢谢

亲切的问候

标签: c#

解决方案


拆分字符串后,将其添加到列表中,将其添加到 HashSet。然后将其转换为列表。这应该删除重复项。


推荐阅读