0
Simple sort this array and next ignore the values identical with prior
0
I thinks it's better practice with this sort of small programs to work with the Console. It's a cleaner environment to code in :)
Copy/Paste this and look how it works.
using System;
namespace ConsoleApplication2
{
public class ArrayProblem
{
public static void Main()
{
int[] values = new int[]
{
10,25,34,67,42,
14,98,76,28,10,
99,82,13,25,76
};
Console.WriteLine(" -----------------------\n");
for(int i = 0; i < values.Length; i++)
{
int temp = values[i];
bool uni = false;
for(int j = 0; j < values.Length; j++)
{
if (i==j){break;}
uni = (temp == values[j]);
if (uni){break;}
}
if (!uni)
{
Console.WriteLine(string.Format(" {0} is unique" ,temp));
}
else
{
Console.WriteLine(string.Format(" ({0} is duplicate)" ,temp));
}
}
Console.WriteLine("\n -----------------------");
Console.ReadLine();
}
}
}
0
You are creating a new empty array each time you click on the enter button. You are not holding on to values after the click event of the enter button has terminated. If you make the array a form level variable it will hold values for the life of the form.
Hope this helps.