改进了一下,方法如下
var text2 = "";
var random = new Random((int)DateTime.Now.Ticks);
const string textArray = "23456789ABCDEFGHGKLMNPQRSTUVWXYZ";
for (var i = 0; i < iVcodeNum; i++)
{
text2 = text2 + textArray.Substring(random.Next() % textArray.Length, 1);
}
return text2;