LinQ:配列で重複を排除する方法Distinct()
VB.NET
' 配列データ作成
Dim
strArray As String() = New String() {"apple", "orange", "pear", "banana", "banana"}
' 配列から文字長でソートして取得
Dim
query1 = From fruit In strArray.Distinct() _
Order By
fruit.Length _
Select
fruit.ToUpper(), fruit.ToLower()
■
C#
// 配列データ作成
string[]
strArray = { "apple", "orange", "pear", "banana", "banana" };
// 配列から文字長でソートして取得
var
query1 = from fruit in strArray.Distinct()
orderby
fruit.Length
select new {
STRUP = fruit.ToUpper(), STRLOW = fruit.ToLower() };
■