When comparing two identical strings they are returning not equal...why?

I really don’t understand this at all? Here is my code. Two identical string when compared are returning false. Can somebody tell me why? Thanks

 print("today - unlockKeyRequired="+unlockKeyRequired+" enteredUsername="+enteredUsername+"<<");//PRINTS CORRECTLY THE FOLLOWING: today - unlockKeyRequired=12345 enteredUsername=12345​<<
		print("today - ALL GOOD");//DOES NOT PRINT
		print("today - password problem with username or password");//THIS PRINTS

Try using String.Compare() instead.

In the end it looks like there was some kind of strange whitespace or carriage return that wouldn’t display or go away using the usual enteredUsername = enteredUsername.TrimEnd(new char[] { '\r', ' ' }); method. I could only tell this by iterating through each character which told me the lengths were different. However, despite this, the string.compare STILL returned false. But then, I switched the string.compare back to a string.Equals and it finally returned true.

So basically I now have it working, but Unity scares me a little bit more.