Posts
231
Comments
64
Trackbacks
4
Kleine Funktion: ToValidChar

Hier eine kleine Funktion um ein beliebiges Objekt in einen Char-Wert umzuwandeln:

static public char ToValidChar(object n) {
      if(n==null) return '\0';
      if(n.GetType() == typeof(char)) {
            return (char)n;
      }
      if(n.GetType() == typeof(string)) {
            if( ((string)n).Length > 0 ) return ((string)n)[0];
      }
      return '\0';
}

posted on Wednesday, March 05, 2008 12:06 PM Print
Comments
No comments posted yet.

Post Comment

Title *
Name *
Email
Url
Comment *  
Please add 1 and 8 and type the answer here: