Hello
(E-Mail Removed),
> Below is the internal implementation of “==”:
>
> ------
> public static bool operator ==(string a, string b)
> {
> return Equals(a, b);
> }
> ------
>
> So you can see that you are really using string.Equals() when you do
> “==”.
>
> String.Compare() performs a culture-sensitive comparison while
> String.Equals() performs an ordinal comparison.
>
> So, since String.Compare() uses culture, I would guess that
> “String.Compare” would be much slower than “==”.
>
> Nevertheless, both operations have different meaning so its no longer
> a matter of what faster or slower, its a matter of what you need to
> have done.
>
> Rene
>
> On Jun 30, 2:07 pm, Alpha83 <taps...@gmail.com> wrote:
>
>> Hi,
>> Is there a code measuring tool that tells you which is more efficient
>> cost-wise. For example, if I were to compare the following two
>> identical code blocks, how do I know, which is more expensive CPU
>> wise :
>> //compare 2 strings
>> 1. if (str1 == str2) ....
>> 2. if (String.Compare(str1, str2, true) == 0) ....
>>
>> Thanks.
>>
String.Compare also allows you to pass an option to do a culture insenstive
comparison.