Capitalize words of string passed into method

    public static string CapitalizeWords(string p)
    {
        string result = string.Empty;

        char[] sep = new char[] { ' ' };
        string[] words = p.Split(sep);

        foreach (string word in words)
        {
            result += word.Substring(0, 1).ToUpper() + word.Substring(1, word.Length - 1) + " ";
        }

        return result.Trim();

    }

Author: kyrathasoft

The only programmer in Glens Fork, Ky.