logical operator

G

Guest

Hi
How would I compare a string to multiple values, ie. do this same action if
string "abc" is equal to string X, or string Y or string Z? I know I can do
it in three nested if-else statement, but is there a smarter way?

TIA
--
 
M

Mattias Sjögren

How would I compare a string to multiple values, ie. do this same action if
string "abc" is equal to string X, or string Y or string Z? I know I can do
it in three nested if-else statement, but is there a smarter way?

stirng s = "abc";
if ( s == X || s == Y || s == Z ) ...



Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top