2

私は VB.Net を使用しており、2 つの 1 次元配列を持っています。両方に共通する要素を見つけるための組み込み関数はありますか? それとも自分で書く必要がありますか?

4

3 に答える 3

9

LINQ 拡張メソッド (VB9) を使用できる場合は、はい - 使用できますEnumerable.Intersect()

dim a as String() = {"blah", "bleak", "blorg", "blue"}
dim b as String() = {"blaah", "bleak", "bleee", "blue"}

' c will contain the intersection, "bleak" and "blue" '
dim c as IEnumerable(Of String) = a.Intersect(b)
于 2009-06-11T16:39:26.877 に答える
1

.net 2.0 http://code.google.com/p/linqbridge/downloads/listにLinqBridge を使用するだけで、intersect メソッドを使用できるはずです。

于 2011-11-02T17:16:46.503 に答える