有没有更有效的方法来完成这个过程?
请注意,我不想使用GUID或任何其他超过5个字符的东西……我必须坚持5个字符。
PS:我认为这没有什么区别,但我的字符串都是区分大小写的。
以下是“随机字符串”部分。
Public Function GetRandomNumbers(ByVal numChars As Integer) As String
Dim chars As String() = { _
"A", "B", "C", "D", "E", "F", _
"G", "H", "I", "J", "K", "L", _
"M", "N", "O", "P", "Q", "R", _
"S", "T", "U", "V", "W", "X", _
"Y", "Z", "0", "1", "2", "3", _
"4", "5", "6", "7", "8", "9", _
"a", "b", "c", "d", "e", "f", _
"g", "h", "i", "j", "k", "l", _
"m", "n", "o", "p", "q", "r", _
"s", "t", "u", "v", "w", "x", _
"y", "z"}
Dim rnd As New Random()
Dim random As String = String.Empty
Dim i As Integer = 0
While i < numChars
random += chars(rnd.[Next](0, 62))
System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)
End While
Return random
End Function