0

Hi,i'm buliding an application which accepts new password when their exists a default password

savedPassword = (Application.UserAppDataRegistry.GetValue("newpassword")) ?   Application.UserAppDataRegistry.GetValue("newpassword").ToString() : "defaultPassword";

but i'm getting an error it says cannnot convert objet to bool..i think theirs something wrong in ternary operator.
Thanx.:)

Edited by __avd: Added [code] tags. Do wrap your programming code blocks within [code] ... [/code] tags

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by Momerath
0

Nothing wrong with it. The first argument must resolve to a true/false (boolean) value. Yours resolves to a object, just as the compiler said.

Try changing it to read:

savedPassword = (Application.UserAppDataRegistry.GetValue("newpassword")) != null ? Application.UserAppDataRegistry.GetValue("newpassword").ToString() : "defaultPassword";
0

Thanx for the reply Momerath but I had done this earlier but it won't accept my default password also when application file is first opened....when new password is not set.

Edited by prathoven: n/a

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.