c#中除开数组中重复的数据

c#中去除数组中重复的数据有一个数组比如int a[5]{0,1,2,1,4},如何变为int a[4]{0,1,2,4},请高手回答。。。

c#中去除数组中重复的数据
有一个数组比如int a[5]={0,1,2,1,4},如何变为int a[4]={0,1,2,4},请高手回答。。。

[解决办法]
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();