CamelCase in C#

Example for versions gmcs 2.0.1

This example uses only regular expressions. First pass replaces all maximum sequences of letters with result of applying CapitalizePart to them (i.e., makes first character uppercase). Second pass replaces all non-letters with empty string.

using System;
using System.Text.RegularExpressions;
 
class Program 
{   static string CapitalizePart(Match m) 
    {   string x = m.ToString();
        return char.ToUpper(x[0]) + x.Substring(1, x.Length-1);
    }
    static void Main() 
    {   string text = Console.ReadLine().ToLower();
        string cc = Regex.Replace(text, "([a-z]+)", new MatchEvaluator(Program.CapitalizePart));
        cc = Regex.Replace(cc, "[^a-zA-Z]+", string.Empty);
        Console.WriteLine(cc);
   }
}