Prev | Current Page 292 | Next

Guy Fouch?©, Trey Nash

"Accelerated VB 2008"

The StringComparison enumeration looks like the following:
Public Enum StringComparison
CurrentCulture
CurrentCultureIgnoreCase
InvariantCulture
InvariantCultureIgnoreCase
Ordinal
OrdinalIgnoreCase
End Enum
The last two items in the enumeration are the items of interest. An ordinal-based comparison
is the most basic string comparison that simply compares the character values of the two
strings based on the numeric value of each character compared (it actually compares the raw
binary values of each character). Doing comparisons this way removes all cultural bias from
the comparisons and increases the efficiency of these comparisons tremendously.
The .NET Framework features a new class called StringComparer that implements the
IComparer interface. Things such as sorted collections can use StringComparer to manage the
sort. The System.StringComparer type follows the same pattern as the IFormattable locale support.
You can use the StringComparer.CurrentCulture property to get a StringComparer instance
CHAPTER 9 n WORKING WITH STRINGS 180
specific to the culture of the current thread. Additionally, you can get the StringComparer
instance from StringComparer.CurrentCultureIgnoreCase to do case-insensitive comparison, as
well as culture-invariant instances using the InvariantCulture and InvariantCultureIgnoreCase
properties.


Pages:
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304
życzenia urodzinowe dieta light felgi aluminiowe poznań pozycjonowanie portal