본문 바로가기
C#/c#

[C#] 배열 또는 리스트에서 중복값 제거

by izen8 2021. 11. 4.
반응형

Enumerable.Distinct 메서드 사용

1) Array

double[] a = new double[] { 1, 100, 100, 200, 100, 300, 400, 500, 600 };
a = a.Distinct().ToArray();

2) List

List<double> b = new List<double>();
b.AddRange(new double[] { 1, 100, 100, 200, 100, 300, 400, 500, 600 });
b = b.Distinct().ToList();



출처: https://tnmsoft.tistory.com/182?category=682054 [바퀴 굴리는 프로그래머]

반응형

댓글