CSharp · Console
using System;
using System.Linq;
public class Program
{
public static void Main()
{
int[] array1 = { 2, 5, 8, 10, 2, 23, 2, 4, 5, 8, 8 };
int[] arraySemRepeticao = array1.Distinct().ToArray();
var arrayAgrupadosRepeticao = array1.GroupBy(x => x)
.Select(a => new
{
Item = a.Key,
Quant = a.Count()
})
.ToArray();
foreach(var a in arraySemRepeticao.OrderBy(x => x))
{
Console.WriteLine(a);
}
Console.WriteLine();
Console.WriteLine("---------------------------------------------");
Console.WriteLine();
foreach(var a in arrayAgrupadosRepeticao)
{
Console.WriteLine(a.Item + " " + a.Quant);
}
}
}