Capitalizing a string using C#
Posted on April 12, 2007 at 19:13I 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:
- 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);
- Based on Regular Expressions (2 examples found here)
- Some other home-baked implementations, mostly scanning through the string for whitespace, and capitalizing new words as they come up.
Am I missing anything?