/ Published in: C#
Makes first letter upper and the rest lower except for names like Mcsomething
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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; } }