List of unique points
I want to create a list of unique, randomly generated points (x, y), but I get duplicate points in the output and I can't figure out why. Here's my code: class Program { static void Main() { List<int[]> UniquePoints = new List<int[]>(); int MaxPoints = 20; generateUniquePoints(UniquePoints, MaxPoints); displayPoints(UniquePoints); } static void generateUniquePoints(List<int[]> lstUniquePoints, int MaxPoints) { Random rnd = new Random(); while (lstUniquePoints.Count < MaxPoints) { int x = rnd.Next(1, 6); int y = rnd.Next(1, 6); int[] Point = { x, y }; while (lstUniquePoints.Contains(Point)) { x = rnd.Next(1, 6); y = rnd.Next(1, 6); Point[0] = x; Point[1] = y; } lstUniquePoints.Add(Point); } } static void displayPoints(List<int[]> lstUniquePoints) { for (int i = 0; i < lstUniquePoints.Count; i++) { Console.WriteLine(lstUniquePoints[i][0] + " " + lstUniquePoints[i][1]); } } }