How to convert text into InitCap

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Given any string in C# as variable, how to convert that into Initial Capital

Ex: "how are you doing?" to be displayed as "How Are You Doing?"
 
Use the following method

public static string PropCase(string strText)
{
return new
CultureInfo("en").TextInfo.ToTitleCase(strText.ToLower());
}
 
To be more precise

- use CultureInfo.CurrentUICulture for UI strings and InvariantCulture for
machine data (e.g. data in DB, which might be mixed up in different
languages and codings)

AlexS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top