Issue in random password generater code


I want ot generate the random password(contains 3 upper case letter and 3 lower case letter along with two number) using the below code.

*i am genrating on one number which later use as ASCII for upper case letter
int val = new Random().Next(26,52)

Here i am generating the character for that generated random number.
string strPwdString = strPwdString +(Char)(‘a’ + val)

But there the code is giving comile time error states that '. '(dot) expected . (+(Char)(‘a’ + val).

Could you please help to resolve this issue.


Correcting your code a bit,

String strPwdString = strPwdString + Convert.ToString(CChar(“a”)+Chr(val))

where val should be a Integer

Dominic :slight_smile:

I used your code but its giving same output as “a” everytime. :frowning:

@Suchi3190, Let me exemplify what I have done,

  1. Hardcoded integer val as 99
    It gave me an output ac

  2. Hardcoded integer val as 68
    It gave me an output aD

Dominic :slight_smile:

tried your requirement, you can use if you need.

pwGen.xaml (8.0 KB)


Thaanks @vvaidya