Trying to learn c# and dont understand why i cant compare string.

if (answere == 'j' || answere == 'J')
            {
                again = true;
            }
            else
                again = false;

How do I do to make this happen in c#?

If the type of answere is string then you must compare against a string.
'j' and 'J' are of type char. To make them string, use "j" and "J".

As simple as that. Thanks.

Does not always has to be complicated. Happy computing!

You cad do it like:

string answare = "j";
bool again = (answare == "j" || answare == "J") ? true : false;

about your issue: as ddanbe explained, (') is a type char, and I presume that variable answare is a type string ("). So these two will no go along. Or use one or the other.

This is a short version where you can choose between true of false.
Mitja

You cad do it like:

string answare = "j";
bool again = (answare == "j" || answare == "J") ? true : false;

No need for the ? : part, it will return true/false anyway. You can also just do:

bool again = answare.ToUpper() == "J";

That one i didnt know before. Youre all wonderfull at this forum!

If you would mark this thread as solved, who knows, what wonderfull and miraculous things we can do for you!

:) Indeed. Maybe we can find out some thing which even Microsoft doesn`t know, and it will be implemented in VS 4.5
:)

Sorry didnt know that i could...

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.