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.:)

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";

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.

I'd have to see more of the code, since this line doesn't 'accept' anything, it just sets a value.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.