opensubscriber
   Find in this group all groups
 
Unknown more information…

a : advanced-dotnet@discuss.develop.com 5 September 2008 • 10:54PM -0400

Re: [ADVANCED-DOTNET] String.Compare seems to fail when it should not
by Simon Robinson

REPLY TO AUTHOR
 
REPLY TO GROUP




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Ā®  http://www.develop.com

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

Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

Related Messages

opensubscriber is not affiliated with the authors of this message nor responsible for its content.