2

私は文字列の配列を持っています:

string[] PropertyIds= new string[5];

クラスのA List( Property)

List<Property> properties = new List<Property>();

クラスPropertyには次のフィールドがあります: PropertyId(string) およびPropertyDesc(string)

List プロパティにはない PropertyIds 配列の PropertyId のすべての値を見つける必要があります。

例えば

 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"),
};

次に、結果はtwothreeになるはずです。

4

1 に答える 1

5

Enumerable.Exceptを使用して、2 つのシーケンスの違いを取得します。

var result = PropertyIds.Except(properties.Select(p => p.PropertyId));
于 2013-01-21T11:06:09.970 に答える