I am writing a code to create a random password without duplicates for my project. My code is the form of randomly picking numbers and letters from the string. However, I would like to ask how to eliminate duplication in string data type, not int.
public  static  class StringUtils
{
    private  const  string PASSWORD_CHARS = 
         "0123456789abcdefghijklmnopqrstuvwxyz" ;
    public  static  string GeneratePassword ( int length)
    {
        var sb = new System.Text.StringBuilder (length);
        var r = new System.Random ();
        for ( int i = 0 ; i <length; i ++)
        {
            int      pos = r.Next (PASSWORD_CHARS.Length);
             char     c = PASSWORD_CHARS [pos];
            sb.Append (c);
        }
        return sb.ToString ();
    }
}
I kept searching and looked for a way, but I couldn't find a solution.
 
    