© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•12mo ago•
16 replies
Faker

✅ Does it matters which operator we use to compare strings, == or string.Equals?

Hello guys, I was just trying to compare 2 strings and my IDE give me this warning of using
string.Equals
string.Equals
. I was wondering if it does matter whether we use
==
==
or
string.Equals
string.Equals
. From what I've read, it doesn't matter if the type is of type string but if it's of another type, like object or generic type (I guess), it does matter. Can someone explain why it would matter please; does this have something to do with comparing references rather than actual values?
DD9CE3EF-94B2-4E06-937C-E39DBBE03E22.png
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Compare Strings better way.
C#CC# / help
13mo ago
✅ Operator ! cannot be applied to type string
C#CC# / help
3y ago
✅ how to avoid string.Join with empty strings?
C#CC# / help
3y ago
✅ Best way to use and compare enums? (Unity)
C#CC# / help
3y ago