Why would you use String.Equals over ==? [duplicate]

It’s entirely likely that a large portion of the developer base comes from a Java background where using == to compare strings is wrong and doesn’t work.

In C# there’s no (practical) difference (for strings) as long as they are typed as string.

If they are typed as object or T then see other answers here that talk about generic methods or operator overloading as there you definitely want to use the Equals method.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)