我有两个列表对象.我将它们组合成一个列表.虽然合并我需要删除重复.TweetID是要比较的字段.
List<TweetEntity> tweetEntity1 = tt.GetTweetEntity(Convert.ToInt16(pno), qdecoded, longwoeid );
List<TweetEntity> tweetEntity2 = tt.GetTweetEntity(Convert.ToInt16(pno), qdecoded);
List<TweetEntity> tweetEntity = tweetEntity1.Concat(tweetEntity2).ToList();
Run Code Online (Sandbox Code Playgroud)
我已将两个列表合并,但无法过滤掉重复项.是否有任何内置函数来删除List <>中的重复项?
你可以使用Union方法.
List<TweetEntity> tweetEntity = tweetEntity1.Union(tweetEntity2).ToList();
Run Code Online (Sandbox Code Playgroud)
但是,你首先覆盖Equals和GetHashCodefor TweetEntity.
| 归档时间: |
|
| 查看次数: |
2478 次 |
| 最近记录: |