string[] tmp = new string[]{"a","b","c".......}; System.Ramdom mRandom=new System.Random(); string result = ""; while(result.length < 3) { int tmpIndex = mRandom.Next(25); string tmpChar = tmp[tmpIndex]; if(result.IndexOf(tmpChar) < 0) result += tmpChar; }
可以用random.nextbytes()方法! Dim rnd As New Random() Dim b(26) As Byte rnd.NextBytes(b) 然后你取b(0),b(1),b(2)的值根据数字去一个放26个字母的字符串里去取,然后组合起来输出 笨办法,不知道可不可以,我也是菜鸟!主要是考虑到不能重复!
System.Ramdom mRandom=new System.Random();
string result = "";
while(result.length < 3)
{
int tmpIndex = mRandom.Next(25);
string tmpChar = tmp[tmpIndex];
if(result.IndexOf(tmpChar) < 0)
result += tmpChar;
}
Dim rnd As New Random()
Dim b(26) As Byte
rnd.NextBytes(b)
然后你取b(0),b(1),b(2)的值根据数字去一个放26个字母的字符串里去取,然后组合起来输出
笨办法,不知道可不可以,我也是菜鸟!主要是考虑到不能重复!