Lastly, you can use the Ordinal and OrdinalIgnoreCase properties to get instances
that compare based on ordinal string comparison rules.
As you may expect, if the culture information attached to the current thread isn??™t what you
need, you can create StringComparer instances based upon explicit locales simply by calling the
StringComparer.Create method and passing the desired CultureInfo representing the locale
you want, as well as a flag denoting whether you want a case-sensitive or case-insensitive comparer.
The string used to specify which locale to use is the same as that for CultureInfo.
When choosing between the various comparison techniques, the general rule of thumb is
to use the culture-specific or culture-invariant comparisons for any user-facing data??”that is,
data that will be presented to end users in some formor fashion??”and ordinal comparisons
otherwise. However, it??™s rare that you??™d ever use InvariantCulture compared strings to display
to users. Use the ordinal comparisons when dealing with data that is completely internal.
Working with Strings from Outside Sources
Within .NET, all strings are represented using Unicode UTF-16 character arrays. However, you
may need to interface with the outside world using some other formof encoding, such as
UTF-8.
Pages:
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305