Home Using OR in if condition with String value in C#.Net
Reply: 1

Using OR in if condition with String value in C#.Net

user3083221
1#
user3083221 Published in 2018-02-13 21:07:21Z

This question already has an answer here:

  • Operator || cannot be applied to type bool and string / string and string 4 answers

How can I put the below statement in C#.Net.

If(strValue =="ABC" || strValue =="EFG" || strValue =="IJK") Some code implementation.

It gives me error (Operand || cannot be applied to type bool or string) , when I use the above statement.

JulienRcs
2#
JulienRcs Reply to 2018-02-14 09:07:35Z

Please try :

        if(strValue.Equals("ABC") || strValue.Equals("EFG") || strValue.Equals("IJK"))
        {

        }

You may not write "if" with a capital i and the function "Equals" work better on string comparison

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.391944 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO