手机
当前位置:查字典教程网 >编程开发 >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#中数组,ArrayList与List对象的区别

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

C# byte数组与Image相互转换的方法

C#数据结构与算法揭秘三 链表

C# 正则判断一个数字的格式是否有逗号的代码

深入理解C#索引器(一种支持参数的属性)与属性的对比

C#生成不重复随机数列表实例

深入理解C#中常见的委托

C#.NET字符串比较中忽略符号的方法

精品推荐
分类导航