List Info

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




Re: String.Compare seems to fail when it should not
user name
2008-09-19 06:44:39
At last, the problem is fixed.

One of the strings was found to be user input (that's a long
story ...)
And users can insert any char they want to ...

We were put on the wrong track, since our db converts the
error log
into ascii chars; what we read in the log was not equal to
what had
happened at runtime! (OMG)

Thanks to anyone who replied.

// Ryan

On Fri, Sep 5, 2008 at 4:17 PM, Ryan Heath
<ryan.q.heathgmail.com> wrote:
> Hi,
>
> See following snippet,
>
> if (0 != string.Compare(str1, str2,
StringComparison.OrdinalIgnoreCase))
> {
>  throw new Exception("Compare failed str1:()
length: str2:()
> length:", 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 DevelopMentorŪ  http://www.develop.com

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


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )