新手上路 求助啦!! 用c# 怎样实现在字符串中随机抽取10个不重复的字符 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //97-122 65-90 byte[] bt = new byte[10]; Random rn = new Random(); int t =0; for(int i=0;i<10;i++) { t=rn.Next(t,26); bt[i] = Convert.ToByte(t + 65); } label1.Text = System.Text.Encoding.ASCII.GetString(bt); copico(一路向北)的算法可能会有重复,需要加条件判断 string str = "用c# 怎样实现在字符串中随机抽取10个不重复的字符"; Random rd = new Random(); List<Char> newChar = new List<char>(); List<int> ln = new List<int>(); int cnt = 0, rnum =0; while(true) { if(cnt>=10) break; rnum = rd.Next(0, str.Length - 1); int l=0; for (; l < ln.Count; l++) { if (ln[l] == rnum) break; } if (l < ln.Count) continue; else { newChar.Add(str[rnum]); ln.Add(rnum); cnt++; } } return newChar.ToArray();给你代码,结贴吧!! 在顶一下拉~! List<Char> newChar = new List<char>(); List<int> ln = new List<int>(); 无法表达Char和int啊 dsoframer excel 独占 请问有调用RS232接口,操作RS232接口的例子吗? 这段代码究竟哪里出问题了? winform中的zedgraphcontrol问题 实现下面功能的webBrowser,该怎么办? 关于WinForm中TreeView的几个疑惑 异步!!! 你好!想请将一个关于 detailsview 中dropdownlist绑定的问题 关于byte[] buffer = new byte[1024];的一个小问题 C#中如何实现自定义字体显示,我想显示宽和高不相等的字体!如瘦高字体。(内详) 求助!c# b/s结构能应对大量的数据录入吗
byte[] bt = new byte[10];
Random rn = new Random();
int t =0;
for(int i=0;i<10;i++)
{
t=rn.Next(t,26); bt[i] = Convert.ToByte(t + 65);
} label1.Text = System.Text.Encoding.ASCII.GetString(bt);
List<int> ln = new List<int>(); int cnt = 0,
rnum =0;
while(true)
{
if(cnt>=10) break;
rnum = rd.Next(0, str.Length - 1);
int l=0;
for (; l < ln.Count; l++)
{
if (ln[l] == rnum) break;
}
if (l < ln.Count) continue;
else
{
newChar.Add(str[rnum]);
ln.Add(rnum);
cnt++;
}
}
return newChar.ToArray();给你代码,结贴吧!!
List<Char> newChar = new List<char>();
List<int> ln = new List<int>();
无法表达Char和int啊