Linq-set-operations
提供:Dev Guides
LINQでの操作の設定
集合演算には4つの演算子があり、それぞれ異なる基準に基づいて結果を生成します。
Operator | Description | C# Query Expression Syntax | VB Query Expression Syntax |
---|---|---|---|
Distinct | Results a list of unique values from a collection by filtering duplicate data if any | Not Applicable | Distinct |
Except | Compares the values of two collections and return the ones from one collection who are not in the other collection | Not Applicable | Not Applicable |
Intersect | Returns the set of values found t be identical in two separate collections | Not Applicable | Not Applicable |
Union | Combines content of two different collections into a single list that too without any duplicate content | Not Applicable | Not Applicable |
個別の例-クエリ式
VB
上記のコードをコンパイルして実行すると、次の結果が生成されます-
Exceptの例-Enumerable.Exceptメソッド
C#
VB
上記のC#またはVBのコードをコンパイルして実行すると、次の結果が生成されます-
Intersectの例-Enumerable.Intersectメソッド
C#
VB
上記のC#またはVBのコードをコンパイルして実行すると、次の結果が生成されます-
Unionの例-Enumerable.Unionメソッド
C#
VB
上記のC#またはVBのコードをコンパイルして実行すると、次の結果が生成されます-