Which way is faster...?

  • Thread starter Thread starter K. Shier
  • Start date Start date
K

K. Shier

Char .Is<Category>
or
Char.GetUnicodeCategory

?


in the Help for the UnicodeCategory Enumeration it says "This enumeration is
used to support Char methods, such as IsUpper." So... If .Is<Category>
just wraps .GetUnicodeCategory, then i assume that the latter is faster.

can anyone accurately confirm or contest this?

Thanks! =)
 
in the Help for the UnicodeCategory Enumeration it says "This enumeration
is
used to support Char methods, such as IsUpper." So... If .Is<Category>
just wraps .GetUnicodeCategory, then i assume that the latter is faster.

can anyone accurately confirm or contest this?

Why don't you do a preformance test and post the results. Do you know how?

~
Jeremy
 
K. Shier,
Generally for this sort of thing I look at which is easier to use in the
context I'm using it.

Is:
If Char.IsUpper(ch) Then
' do something
End If

Easier to read/use then:
If Char.GetUnicodeCategory(ch) = UnicodeCategory.UppercaseLetter Then
' do something
End If

I will almost always tend to favor the first over the second. Considering
that IsUpper is:
- shorter
- I don't need to remember what categories I am verifying against
- Char.IsLetter, Char.IsLetterOrDigit, Char.IsNumber, Char.IsPunctuation,
Char.IsSeparator, and Char.IsSymbol: all actually check for a number of
Unicode Categories each.
- Char.IsWhiteSpace actually checks for a Unicode Category or some special
characters.

Hope this helps
Jay
 
Back
Top