Instead,we can use “TextInfo” class to achieve the solution in a easier manner. The below function used to convert the given string’s first character alone as a Capital letter.
using System.Globalization; using System.Threading; public string changeName(string inputname) { string modifiedname = string.Empty; string[] names = inputname.Split(' '); foreach (string name in names) { CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture; TextInfo txtinfo = cultureInfo.TextInfo; string temp=txtinfo.ToTitleCase(name); modifiedname = string.Concat(temp, " "); } return modifiedname; }