Why does this simple If statement go to the Else Sequence?

Hello @Peter_Peter,

Try comparing with the following sentence:

The Is operator is not adequate when comparing two String variables. According Microsoft’s documentation:

Is Operator − It compares two object reference variables and determines if two object references refer to the same object without performing value comparisons.

In this cases, it’s better to use some native String comparators.

Alan C.

Hi @Peter_Peter

You can also just use the “=” - operator. Then it’s working properly.

Luca H.

I know that this is an option. But im wondering why this if statement goes into the Else sequence.
Because if I use “Isnot” then it goes into the Then sequence.

It goes to the Else because variable1 is not variable2. They have the same value but as @mancl0ud said the Is operator checks to see if they refer to the same object.