Re: String.Compare seems to fail when it should not

John Warner <[email protected]>
Newsgroups gmane.comp.windows.devel.dotnet.advanced
Organization John Warner
Message-ID <024801c90f63$9c18f4f0$3d02a8c0@Pluto>
Correct me as I may be all wrong but I thought dotnet recommends that you
not count on -1,0,1 being indicators for true and false? Have I got this
all wrong (extremely likely)?

John Warner




> -----Original Message-----
> From: Discussion of advanced .NET topics.
> [mailto:[email protected]] On Behalf Of Ryan Heath
> Sent: Friday, September 05, 2008 10:18 AM
> To: [email protected]
> Subject: [ADVANCED-DOTNET] String.Compare seems to fail when
> it should not
>
>
> Hi,
>
> See following snippet,
>
> if (0 != string.Compare(str1, str2,
> StringComparison.OrdinalIgnoreCase))
> {
>   throw new Exception("Compare failed str1:({0}) length:{1}
> str2:({2}) length:{3}", str1, str1.Length, str2, str2.Length); }
>
> it throws, for instance, with "Compare failed str1:(-mylife) length:7
> str2:(-MYLIFE) length:7"
>
> Obviously something is really wrong here...
> Has anyone seen this behavior before, or has anyone some tips
> how to investigate this problem?
>
> // Ryan
>
> ===================================
> This list is hosted by DevelopMentorR  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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.