如何随机生成符号? 注意,不是数字也不是字母,是符号,例如“】【=--=-0=-0……*@(#!@&#)!(@#。,”生成的符号数量是变量,例如随机生成包含5个符号的字符串。这样如何生成呢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public static string RandomStrX(int pStrLen,int seed ) { string ct = @"~!@#$%^&*()_+-={}|[]\:;'<>?,./"; string code = ""; int randValue = -1; Random rand = new Random(unchecked((int)DateTime.Now.Ticks + seed)); for (int i = 0; i < pStrLen; i++) { randValue = rand.Next(0, ct.Length - 1); code += ct[randValue]; } return code; } 请问参数seed 是什么? seed 随便乱定义的,因为是采用时间做种子,如果连续调用 RandomStrX,会得到同样的值,所以额外增加一个 seed 参数,允许更改种子值。string s1 = RandomStrX(10,1)string s2 = RandomStrX(10,2)string s3 = RandomStrX(10,3) c#一个比较棘手的窗体问题,请教各位大侠 c#菜鸟请教 如让让我的这个弹出窗口屏幕居中?(WEB) 赋的值全部清空掉 如何校验日期 NET群5347943 求解释,直接看code 求大神如何用GridView在页面显示数据库中的信息 我是菜鸟哈!我问一下各位高手,一般c#入门应该看些什么书好呢??? 出差在外,各位网友大救命! 设计一个功能,每月定时从充值卡里扣除本月费用,如何设计? 一个关于WCF的问题,请教高手帮忙解答
string ct = @"~!@#$%^&*()_+-={}|[]\:;'<>?,./";
string code = "";
int randValue = -1;
Random rand = new Random(unchecked((int)DateTime.Now.Ticks + seed));
for (int i = 0; i < pStrLen; i++) {
randValue = rand.Next(0, ct.Length - 1);
code += ct[randValue];
}
return code;
}
请问参数seed 是什么?
所以额外增加一个 seed 参数,允许更改种子值。string s1 = RandomStrX(10,1)
string s2 = RandomStrX(10,2)
string s3 = RandomStrX(10,3)