(this IEnumerable
// 概要:
// 既定の等値比較子を使用して値を比較することにより、シーケンスから一意の要素を返します。
//
// パラメーター:
// source:
// 重複する要素を削除する対象となるシーケンス。
//
// 型パラメーター:
// TSource:
// source の要素の型。
//
// 戻り値:
// ソース シーケンスの一意の要素を格納する System.Collections.Generic.IEnumerable
//
// 例外:
// System.ArgumentNullException:
// source が null です。
0 1 2 3 4 5 4 3 2 1 0 の重複を取り除く
using System;
using System.Linq;
namespace SampleCode {
class Program {
static void Main(string[] args) {
int[] num = { 0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0 };
foreach (var n in num.Distinct()) {
Console.WriteLine(n);
}
}
}
}
実行結果
0 1 2 3 4 5
0 件のコメント:
コメントを投稿