------解决方案--------------------
int[] a = { 0, 1, 2, 1, 4 }; int[] result = a.Distinct().ToArray();
------解决方案--------------------
非Linq方法
C# code
int[] a = { 0, 1, 2, 1, 4 };
List<int> temp = new List<int>();
foreach (int i in a)
{
if (temp.Contains(i)) continue;
temp.Add(i);
}
int[] result = temp.ToArray();