创建一个函数,它将生成一个字符串0f 8个字母数字字符 [英] create a function which will generate a string 0f 8 alphanumeric character
本文介绍了创建一个函数,它将生成一个字符串0f 8个字母数字字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的朋友,
任何人都可以帮我创建一个函数,生成一个包含
8字符的字符串。它必须是字母数字的组合。
请帮助我。
Dear Friend,
Can any body help me to create a function which will generate a string containing
8 character. It must be combination of alphanumeric always.
Please help me on this.
推荐答案
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
var random = new Random();
var result = new string(
Enumerable.Repeat(chars, 8)
.Select(s => s[random.Next(s.Length)])
.ToArray());
参考< a href =http://stackoverflow.com/questions/1344221/how-can-i-generate-random-alphanumeric-strings-in-c>这个 [ ^ ]
我们不做你的作业!
亲自试试,你可能会发现它并不像你想象的那么难......
We don't do your homework!
Try it yourself, you may find it is not as difficult as you think...
你做过最小的rersearch - 你的问题输入谷歌 [ ^ ]并获得一些优秀的描述和示例代码。
这已经解决了很多已经过了几次。
Did you do even the minimum rersearch - type your question into google [^]and get some excellent descriptions and sample code.
This has been solved many times already.
这篇关于创建一个函数,它将生成一个字符串0f 8个字母数字字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文