A preserved archive of the Logical Gamers community forums, 2009-2025. The original threads and posts, served read-only. Registration, posting and private messages are gone for good.

[C#] Random String

1.1k views · started by Chad ·
#1
[C#] Random String
You can use this to create a keygen, random string, etc etc...

        public string Random_String(int Length)
{
Random random = new Random();
string characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
string rand = string.Empty;

for (int i = 0; i < Length; i++)
{
rand += characters[random.Next(0, characters.Count())];
}

return rand;
}
#2
a more appropriate characters string would be

string characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; 


Just so that it contains lower and capital cases. Nice function though

---------- Post added at 06:00 PM ---------- Previous post was at 06:00 PM ----------

a more appropriate characters string would be


string characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";


Just so that it contains lower and capital cases. Nice function though
#3
Nice work :)

It's simple and effective.
#4
MattSmith wrote:
a more appropriate characters string would be

string characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; 


Just so that it contains lower and capital cases. Nice function though

---------- Post added at 06:00 PM ---------- Previous post was at 06:00 PM ----------

a more appropriate characters string would be

string characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; 


Just so that it contains lower and capital cases. Nice function though


Nice double post. That is how the character string was, but I had just made a program to log into a database and make a random string so I had edited down the random string characters. It was that before.
#5
Chad wrote:
Nice double post. That is how the character string was, but I had just made a program to log into a database and make a random string so I had edited down the random string characters. It was that before.


Wasnt a doubole post, it was lg fuckin up.