Well if you're certain you've checked the code for typos etc. and it's
failing as you claim, that does seem odd :)  The only possibilities I can
think of (and both of these seem like very long shots) are...

1. Check the culture settings that your code is working in. I think that
override of String.Compare() is culture-dependant, so maybe there's some
unusual culture that doesn't recognize eg. 'r' and 'R' as being equivalent?
2. Check the actual unicode values of the characters in your strings. Is
it possible that the 'r' (taking one random character as an example)
actually isn't an 'r' but is some other unusual unicode character that
just happens to look like an 'r' when displayed in your default font?

Simon

>Yeah, that will teach me to post some contrived code to the list :)
>But the production code is really working that way, String.Compare doesn't
>return zero for
>strings that seem to be equally to me.
>
>At first I thought the internal representation of the strings where not
>equal, so I logged the length of the strings.
>But even their lengths are the same! :S
>
>Anyone another idea how to tackle this?
>
>A lot of entries that fail contain an i, so I immediately thought about
the
>turkish-i problem,
>but I have found another entry that failed to without an i in it:
>romA vs ROMA
>
>// Ryan
>
>On Fri, Sep 5, 2008 at 4:54 PM, Simon Robinson
<[EMAIL PROTECTED]>wrote:
>
>> It works fine for me (other than that your code doesn't compile because
>> you need String.Format(....) inside the exception constructor).
>>
>> Are you sure there isn't at typo or something in your code?
>>
>> My test code is:
>>
>> // code works fine - string.Compare() returns 0 so no exception
>> string str1 = "-mylife";
>> string str2 = "-MYLIFE";
>> if (0 != string.Compare(str1, str2, StringComparison.OrdinalIgnoreCase))
>> {
>>  string msg = string.Format("Compare failed str1:({0}) length:{1}
>> str2:({2}) length:{3}", str1, str1.Length, str2, str2.Length);
>>  throw new Exception(msg);
>> }
>>
>> ===================================
>> This list is hosted by DevelopMentor(R)  http://www.develop.com
>>
>> View archives and manage your subscription(s) at
>> http://discuss.develop.com
>>
>
>===================================
>This list is hosted by DevelopMentor®  http://www.develop.com
>
>View archives and manage your subscription(s) at
http://discuss.develop.com

===================================
This list is hosted by DevelopMentor®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to