一、整数随机数 Random rd= new Random(); int n = ran.Next(10); int p = rd.Next(1, 100); 二、字符和布尔随机数 固定字符串随机取 public string Get_stringRandom(string[] arr) { Random ran = new Random(); int n = ran.Next(arr.Length - 1); return arr[n]; } string[] arr = { "abc", "green", "Tom", "C#", "java" }; Get_stringRandom(arr); 随机获取布尔值 public bool Generate_boolRandom() { bool[] arr = { true, false }; Random ran = new Random(); return arr[ran.Next(2)]; } Response.Write(Generate_boolRandom()); 生成一个随机字符串(支持英文大小写字母/数字混合)...
Is this you? As a journalist, you can create a free Muck Rack account to customize your profile, list your contact preferences, and upload a portfolio of your best work.
Claim your profile
Get in touch with double
Contact double, search articles and posts on X, monitor coverage, and track replies from one place.
Learn more about Muck Rack