I have come across a little problem while I'm trying to learn arrays. So the idea is that I need to print out the unique elements in an array. When I run the program, its printing out more than the number of values in the array lol. I'm sorry if this is a super simple and dumb question but i'm not seeing the problem with it. Language is c#.
static void Main(string[] args)
{
int[] numbers = new int[10];
Random random = new Random();
for (int i = 0; i < 10; i++)
{
numbers[i] = random.Next(0, 10);
}
Array.Sort(numbers);
foreach (var num in numbers)
{
Console.Write("{0}, ", num);
}
Console.WriteLine("");
for (int i = 0; i < 10; i++)
{
for (int j = 1; j < 10; j++)
{
if (numbers[i] == numbers[j])
{
break;
}
else
{
Console.Write(numbers[i] + ", ");
}
}
}