How to change the Title Case of a string to Uppercase in C#?

  1. using System.Globalization;  
  2. using System.Threading; 
  3. // The below function takes the string and split it using space and change the first character alone to //capital letter
  4. // Input : i love india
  5. // Output: I Love India
  6. public string changeName(string inputname)  
  7. {  
  8.     string modifiedname = string.Empty;  
  9.     string[] names = inputname.Split(' ');  
  10.     foreach (string name in names)  
  11.     {  
  12.             CultureInfo cultureInfo   = Thread.CurrentThread.CurrentCulture;  
  13.             TextInfo txtinfo = cultureInfo.TextInfo;  
  14.             string temp=txtinfo.ToTitleCase(name);  
  15.             modifiedname = string.Concat(temp, " ");  
  16.     }  
  17.     return modifiedname;