次の方法で共有


Comparing strings in Whidbey

There are new guidelines for comparing strings in Whidbey. The summary has the main points:

Summary: Code owners previously using the InvariantCulture for string comparison, casing, and sorting should strongly consider using a new set of String overloads in Microsoft .NET 2.0. Specifically, data that is designed to be culture-agnostic and linguistically irrelevant should begin specifying overloads using either the StringComparison.Ordinal or StringComparison.OrdinalIgnoreCase members of the new StringComparison enumeration. These enforce a byte-by-byte comparison similar to strcmp that not only avoids bugs from linguistic interpretation of essentially symbolic strings, but provides better performance.

Then, there are lots of gorey details. String comparison is far more complicated than it seems at first.

Comments

  • Anonymous
    June 11, 2005
    re: String comparison is far more complicated that it seems at first.

    No doubt! Check-out Michael Kaplan's blog at http://blogs.msdn.com/michkap/ for all the gory details about internationalization.
  • Anonymous
    June 11, 2005
    Thanks for the update!