When researching different ways of title casing a string in .NET using C# I came across two methods other than my own custom solution.
Using Regular Expressions:
This method looks at the boundary of every word, and title cases the first character after each boundary.
After doing some tests with both methods, I found the Thread method to be quite faster than the regular expression method, even when the Regex was compiled. Doing 10000 title case conversions, I got the following results.
Threading Method - 00:00:00.0937500
Regex Method - 00:00:00.7656250
Regex Compiled - 00:00:00.5000000
Written By: mycodeshare on August 03, 2009 at 22:38
Submit a comment, suggestion, or additional information about this snippet
If you login or register,
you'll be able to post a comment or provide feedback about this snippet.
Comments
That title casing method from the System.Threading.Thread class is definitely faster than my former approach to this problem.
Thanks!!!
Written By: thomas036 on October 13, 2009 at 00:25