Return to Snippet

Revision: 58524
at July 20, 2012 05:28 by lance


Initial Code
internal string TurnFirstToUpperAndRestLower(string input)
        {
            if (!string.IsNullOrEmpty(input))
            {
                string theRest = null;
                string first = string.IsNullOrEmpty(input.Substring(0, 1)) ? null : input.Substring(0, 1).ToUpper();
                if (input.Length > 1 && input.Substring(0, 1).ToUpper() != "M" && input.Substring(1, 1).ToUpper() != "C")
                {
                    theRest = string.IsNullOrEmpty(input.Substring(1, input.Length - 1)) ? null : input.Substring(1, input.Length - 1).ToLower();                
                }
                else
                {
                    theRest = input.Length > 1 ? input.Substring(1, input.Length - 1) : null;
                }
                return first + theRest;
            }
            else
            {
                return null;
            }
        }

Initial URL

                                

Initial Description
Makes first letter upper and the rest lower except for names like Mcsomething

Initial Title
Change person's name to upper and lower

Initial Tags

                                

Initial Language
C#