Capitalizing a string using C#

I was in need of a quick way to capitalize all of the words in a string (and though to check with Google before writing my own implementation). Here is what I found:

  1. This one is built-in to .Net, but can be slow at times (and some people do not like the way that it handles capitalizations of Unicode strings)
System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(value);
  1. Based on Regular Expressions (2 examples found here)
  2. Some other home-baked implementations, mostly scanning through the string for whitespace, and capitalizing new words as they come up.

Am I missing anything?

Tagged , , , , . Bookmark the permalink.

Leave a Reply