In some languages (e.g. C++) you can't use operators like == for string comparisons as that would compare the address of the string object, and not the string itself. However, in C# you can use == to compare strings, and it will actually compare the content of the strings. But there are also string functions to handle such comparisons, so my question is; should you?
Given two strings:
string aa = "aa";
string bb = "bb";
Should you compare them like this:
bool areEqual = (aa == bb);
Or should you use the Equal function, like this:
bool areEqual = aa.Equals(bb);
Is there any technical difference anyway? Or reasonable arguments for best practice?
std::string
can be compared with operator==. It'schar[]
andchar *
that can't. The term string is somewhat ambiguous in C++. – Barometry