In C#, is String.CompareOrdinal(strA, strB)
equivalent to String.Compare(strA, strB, StringComparison.Ordinal)
?
I checked the document at https://msdn.microsoft.com/en-us/library/e6883c06.aspx and it doesn't mention this.
In C#, is String.CompareOrdinal(strA, strB)
equivalent to String.Compare(strA, strB, StringComparison.Ordinal)
?
I checked the document at https://msdn.microsoft.com/en-us/library/e6883c06.aspx and it doesn't mention this.
They both do the same thing. You can follow the source from https://referencesource.microsoft.com
and
The code paths are nearly identical
In fact the only diffrence is the later has a quick check, so if you have Instruction OCD you can statistically save your self a couple of cycles maybe
if ((strA.m_firstChar - strB.m_firstChar) != 0)
{
return strA.m_firstChar - strB.m_firstChar;
}