RosettaCodeData/Task/Remove-duplicate-elements/C-sharp/remove-duplicate-elements-1.cs

6 lines
147 B
C#

int[] nums = { 1, 1, 2, 3, 4, 4 };
List<int> unique = new List<int>();
foreach (int n in nums)
if (!unique.Contains(n))
unique.Add(n);