"==
" is an operator that can be overloaded to perform different things based on the types being compared.
The default operation performed by "==
" is a.Equals(b);
Here's how you could overload this operator for string types:
public static bool operator == (string str1, string str2)
{
return (str1.Length == str2.Length;)
}
Note that this is different than str1.Equals(str2);
Derived classes can also override and redefine Equals()
.
As far as "best practices" go, it depends on your intent.