Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I reset a PasswordChar?

Tags:

c#

I want to make my PasswordChar in a box empty when a user clicks a button (so they can confirm they wrote it right, it's easier than having to type it twice)

However, when I do:

password.PasswordChar = null;

It says

Cannot convert null to 'char' because it is a non-nullable value type

Setting it to '' says it's an empty char, and ' ' just makes it a space. What do I do?

like image 564
Minicl55 Avatar asked Jul 26 '13 02:07

Minicl55


3 Answers

You can use:

password.PasswordChar = '\0';

\0 refers to a null character.

like image 61
Prix Avatar answered Oct 06 '22 04:10

Prix


You should be able to do this:

password.PasswordChar = '\0';
like image 26
Mike Perrenoud Avatar answered Oct 06 '22 03:10

Mike Perrenoud


password.PasswordChar = '\u0000';

'\u0000' means null character in Unicode and it does the same thing as '\0'

Beware that single quote is using to represent char.

like image 20
V-SHY Avatar answered Oct 06 '22 03:10

V-SHY