Posts Tagged ‘Static’

Char/Character Class Shared Functions/Methods

Thursday, March 12th, 2009

Not everyone realises that many of the base types in .NET have their own shared (or static for C#ers) methods which you can use as utility functions.

For example, the Char class has some very useful ones, including…

  • IsControl (is the parameter a control character)
  • IsDigit (I think this is numeric, or decimal point and possibly minus sign)
  • IsLetterOrDigit
  • IsLower (lower case – small letters as opposed to capitals)
  • IsNumber
  • IsPunctuation
  • IsSeparator (I think this is punctuation or whitespace – stuff that isn’t part of a word)
  • IsSymbol (dingbats style stuff I think)
  • IsUpper (capitals)
  • IsWhitespace (space, tabs, non-breaking (nbsp) etc)

These are fairly easy to call – if you have a Char variable called “c”, you just do eg.

If Char.IsWhitespace(c) Then MsgBox(“Is whitespace”)