CSharp examples for System:Char
Capitalizes first word letter and removes spaces and special characters.
using System.IO;//ww w .j a va 2s. c om using System; public class Main{ /// <summary> /// Capitalizes first word letter and removes spaces and special characters. /// </summary> /// <param name="name">String to make class name from.</param> /// <returns>Class name.</returns> public static string BuildClassName( string name ) { char[] chars = name.ToCharArray(); bool makeUpper = true; for ( int i = 0; i < chars.Length; i++ ) { char c = chars[ i ]; if ( makeUpper ) { chars[ i ] = Char.ToUpper( c ); makeUpper = false; } if ( Char.IsWhiteSpace( c ) ) makeUpper = true; else if ( Char.IsSymbol( c ) || Char.IsPunctuation( c ) ) chars[ i ] = ' '; } return new string( chars ).Replace( " ", null ); } }