C# Program to Check Given Strings are Equal or Not Using equal to (==) Operator
Given two strings we need to check if they are equal by using the == operator. The == Operator compares the reference identity i.e. whether they are referring to the same identity in the heap. If they are equal then it will return true, otherwise, return false.
Input String 1 : geeks String 2 : geeks Output : Equal Input String 1 : geeks String 2 : geeqs Output : Not Equal
For the given two strings compare them by using == operator
- If it returns true then the strings are equal.
- If it returns false then the strings are not equal.
But the == operator might not work as expected when we are comparing strings whose reference identities are not the same. Let us understand with the help of the below example: