Re: String.Compare seems to fail when it should not
Simon Robinson <[email protected]>
| Newsgroups | gmane.comp.windows.devel.dotnet.advanced |
|---|---|
| Message-ID | <LISTSERV%[email protected]> |
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