Search code examples
c#asp.nettitle-case

Capitalize each word in string that has no spaces


I am trying to figure out if there are existing libraries/methods that would allow you to capitalize each word in a string, however the words have no spaces. For example:

"blueparrot" should be converted to "BlueParrot"

I know that if there were spaces, I can accomplish this with:

var textInfo = new CultureInfo("en-US", false).TextInfo;
textInfo.ToTitleCase("blue parrot");

However, without the spacing, the outcome is

Blueparrot


Solution

  • There is no easy solution to this except to say that something puts that string of 2 words together to start with, it is at that point that you need to either provide the information on where the word break is, or format it appropriately.