手机
当前位置:查字典教程网 >编程开发 >C#教程 >向一个数组中插入一个1~100的随机数
向一个数组中插入一个1~100的随机数
摘要:namespaceConsoleApplication2{classProgram{staticvoidMain(string[]args)...

namespace ConsoleApplication2 { class Program { static void Main(string[] args) { List<int> list = new List<int>(); Random ran = new Random(); while(true) { if (list.Count >= 100) { break; } int s = ran.Next(1, 101); if (!list.Contains(s)) { list.Add(s); } } list.Sort(); foreach (int i in list) { Console.Write(i + " "); } Console.ReadKey(); } } }

【向一个数组中插入一个1~100的随机数】相关文章:

c# 方法可变数量的参数

C# 16进制与字符串、字节数组之间的转换

c#中虚函数的相关使用方法

C#数据结构与算法揭秘二

c#循环中产生伪随机数

C#数组学习相关资料整理

C#中怎么将一个List转换为只读的

浅析C#中数组,ArrayList与List对象的区别

提取HTML代码中文字的C#函数

将数组中指定数量的元素移动数组后面的实现代码

精品推荐
分类导航