1  Hashtable hashtable = new Hashtable();
 2             Random rm = new Random();
 3             int RmNum = 5; //随机数个数
 4             for (int i = 0; hashtable.Count < RmNum; i++)
 5             {
 6                 int nValue = rm.Next(-5,5);//随机数范围
 7                 if (!hashtable.ContainsValue(nValue) && nValue != 0)
 8                 {
 9                     hashtable.Add(nValue, nValue);
10                     Console.WriteLine(nValue.ToString());
11                 }
12             }

 

相关文章:

  • 2021-09-03
  • 2022-01-19
  • 2022-02-19
  • 2021-10-27
  • 2021-10-19
  • 2021-12-22
  • 2022-12-23
  • 2021-10-19
猜你喜欢
  • 2021-12-16
  • 2022-12-23
  • 2022-01-11
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案