WTF Next?

Dev ramblings from a master of nothing.

  Home  |   Contact  |   Syndication    |   Login
  130 Posts | 0 Stories | 77 Comments | 0 Trackbacks

News

INETA Community Speakers Program
GeeksWithBlogs.net: WTFNext's hosting!

View Stacy Vicknair's profile on LinkedIn

Twitter







Tag Cloud


Archives

Post Categories

Community Links

User Groups

Char.IsDigit and Char.IsNumber are both methods within the System namespace. The methods themselves are almost confusing in name at first glance. You might think that they do the same thing, but then why have both?

Well, because they don't do the same thing. IsDigit refers to only the decimal digits whereas IsNumber can refer to anything in the numeric Unicode category. So, if you just want decimal, stick with IsDigit. Otherwise, you'll be getting a lot more than you bargained for if cleaning data this way.

I'll leave you with a quick example of IsDigit in use for string cleaning:

Private Function StripNonDigitData(ByVal input As String) As String
    Dim output As New StringBuilder("")
    For Each c As Char In input
        If Char.IsDigit(c) Then
            output.Append(c)
        End If
    Next
    Return output.ToString
End Function

 

P.S. Stay tuned, I'm working on a quick series to bring threading back down to a mere mortal level.

EDIT: I've revisited this article to shed more light on IsDigit, read on to prevent any more mistakes!

 

Technorati Tags: ,,
posted on Tuesday, December 09, 2008 3:15 PM