469,619 Members | 1,963 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,619 developers. It's quick & easy.

logical operator

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

Nov 17 '05 #1
1 1161
>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

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Nagib Abi Fadel | last post: by
80 posts views Thread by Christopher Benson-Manica | last post: by
3 posts views Thread by Filip Kratochvil | last post: by
8 posts views Thread by Chua Wen Ching | last post: by
23 posts views Thread by Cor | last post: by
2 posts views Thread by ThunderMusic | last post: by
9 posts views Thread by marko | last post: by
3 posts views Thread by gallows | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.