ArrayList list = new ArrayList(); Random rd = new Random(); for (int i = 0; i <10; i++) { int rNumber = rd.Next(0, 10); //是否包含当前数字 if (!list.Contains(rNumber)) { list.Add(rNumber); } else { i--; } } for (int i = 0; i < list.Count; i++) { Console.WriteLine(list[i]); } Console.ReadKey();