数组里的数据如何提出来

来源:百度知道 编辑:UC知道 时间:2024/05/18 10:12:46
有一个数组:
string[] chars = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9","a", "b", "c", "d", "e", "f", "g", "h", "i"
,"j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","A", "B", "C", "D", "E", "F", "G", "H", "I"
,"J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","~","!"

10位
Random rnd = new Random();
string str="";
for(int i=0;i<10;i++)
{
str += chars[rnd.Next(chars.Length).ToString()];
}

随机数r,chars[r]

不是随机数?
那就得到n,chars[n]

不是说随机数?

终于搞定了...不知道效率怎么样?试试吧...
...read()数字最大不能超过int32....不过一般用不着那么大的吧...先这样吧..有问题再PM我..
程序没有说明,应该可以看懂吧..

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication6
{
class Program
{
static void Main(string[] args)
{
char[] chars = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9','a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'
,'j','k','l','m','n','o','p','q','r','s','t'