Function to generate random password in c#

Function to generate random password in c#

Generate Random password according to your length. 

public string RandomListOfStringCharecters(int length)
{
string temp = “ABCDEFGHIJKLMNOPQRSTUVWXYZ0987654321!@#$%^&*()abcdefghijklmnopqrstuvwxyz”;
Random rand = new Random();
string output = “”;
int j = 0;
for (int i = 0; i < length; i++)
{
j = rand.Next(temp.Length);
output += temp[j].ToString();
}
return output;
}

 

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply