手机
当前位置:查字典教程网 >编程开发 >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# 16进制与字符串、字节数组之间的转换

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

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

C# 中将数值型数据转换为字节数组的方法

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

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

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

C#中字符串的加密的源码

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

基于使用递归推算指定位数的斐波那契数列值的解决方法

精品推荐
分类导航