0

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.

2
  • The if clause you posted doesn't look wrong. Could you please add more code? Actually, if you use Visual Studio, the invalid line should be underlined in red. Commented Feb 13, 2018 at 21:35
  • your code is pretty straight forward and right ,provide more code snippet for better answers Commented Feb 14, 2018 at 7:32

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.