C# - 生成10个字符随机字母数字字符串的最有效方法是什么?

Ste*_*ack 2 c# string random

在c#中生成10个字符的随机字母数字字符串的最有效方法是什么?

juF*_*uFo 5

http://msdn.microsoft.com/en-us/library/system.io.path.getrandomfilename.aspx

string randomName = Path.GetRandomFileName();
randomName = randomName.Replace(".", string.Empty);

// take substring...
Run Code Online (Sandbox Code Playgroud)

例如:

?Path.GetRandomFileName();
"rlwi1uew.5ha"
?Path.GetRandomFileName();
"gcwhcoiy.vxl"
?Path.GetRandomFileName();
"2pzyljzf.k41"
?Path.GetRandomFileName();
"kyjzcccf.d3c"
Run Code Online (Sandbox Code Playgroud)