// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Text.RegularExpressions; namespace E { public class MainClass { public static string ToCapital(string s) { string res = s.Substring(0,1).ToUpper() + s.Substring(1).ToLower(); MatchCollection mc = Regex.Matches(s, " [a-z]"); for(int i = 0; i < mc.Count; i++) { res = res.Replace(mc[i].Groups[0].ToString(), mc[i].Groups[0].ToString().ToUpper()); } return res; } public static void Main(string[] args) { Console.WriteLine(ToCapital("dan mikkelsen")); } } }