0
protected void Button3_Click(object sender, EventArgs e)
    {

        GetRandomPassword();
    }


    public static string GetRandomPassword(int length)
    {

        char[] chars = "$%#@!*abcdefghijklmnopqrstuvwxyz1234567890?;:ABCDEFGHIJKLMNOPQRSTUVWXYZ^&".ToCharArray();
        string password = string.Empty;
        Random random = new Random();

        for (int i = 0; i < length; i++)
        {
            int x = random.Next(1, chars.Length);

            if (!password.Contains(chars.GetValue(x).ToString()))
                password += chars.GetValue(x);
            else
                i--;

        }
        return password;

    }


}

Hi Everyone
This is my code i want generate random password but wt my problems is display the error is No overload for method 'GetRandomPassword' takes '0' arguments How to slove this error plz help me

Edited by Dani: Formatting fixed

2
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by Nithyamaha
0

Hi
I am using asp.net with c#.net my requirments is when i click the button on that time open the browser i search so many sites but i did't get the answer anyone help with me

0

hello Nithyamaha

as you can see

public static string GetRandomPassword(int length)
{

char[] chars = "$%#@!*abcdefghijklmnopqrstuvwxyz1234567890?;:ABCDEFGHIJKLMNOPQRSTUVWXYZ^&".ToCharArray();
string password = string.Empty;
Random random = new Random();
for (int i = 0; i < length; i++)
{
int x = random.Next(1, chars.Length);
if (!password.Contains(chars.GetValue(x).ToString()))
password += chars.GetValue(x);
else
i--;
}
return password;
}
}

requires one parameter, where in you call the method

GetRandomPassword();

without a parameter.

you should enter an integral value as a parameter to it.

GetRandomPassword(25);

so the password would be 25 characters in length.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.