int[] int_array = new int[] {1,4,5,4,3,5,1 }; int[] repeat_array = int_array.GroupBy(a=>a).Where(a=>a.Count()>1).Select(a=>a.Key).ToArray(); /* [0] 1 int [1] 4 int [2] 5 int */
int[] array = new int[] { 1, 4, 5, 4, 3, 5, 1 }; int[] newArray = (from i in array group i by i into grouped where grouped.Count() > 1 select grouped.Key).ToArray();
int[] repeat_array = int_array.GroupBy(a=>a).Where(a=>a.Count()>1).Select(a=>a.Key).ToArray();
/*
[0] 1 int
[1] 4 int
[2] 5 int */
int[] array = new int[] { 1, 4, 5, 4, 3, 5, 1 };
int[] newArray = (from i in array
group i by i into grouped
where grouped.Count() > 1
select grouped.Key).ToArray();