我有一个字符串数组:
string[] PropertyIds= new string[5];
Run Code Online (Sandbox Code Playgroud)
甲List类(Property)
List<Property> properties = new List<Property>();
Run Code Online (Sandbox Code Playgroud)
该类Property有以下字段:
PropertyId(string)和PropertyDesc(string)
我必须在数组PropertyIds中找到PropertyId的所有值,这些值不在List属性中.
例如
string[] PropertyIds= new string[] { "one", "two", "three" };
List<Property> properties = new List<Property>()
{
new Property("one","This is p1"),
new Property("Five","This is p5"),
new Property("six","This is p6"),
};
Run Code Online (Sandbox Code Playgroud)
然后我的结果应该是两个和三个.
使用Enumerable.Except从两个序列中获得差异:
var result = PropertyIds.Except(properties.Select(p => p.PropertyId));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
296 次 |
| 最近记录: |