Sunday, August 9, 2009

Code: Capitalize first letter of every word in a string

Microsoft.VisualBasic.Strings.StrConv(item.Name, Microsoft.VisualBasic.VbStrConv.ProperCase, 0);

The string class in C# has built in methods for making all characters in a string upper or lower case, but nothing to capitalize the first letter in every work. However there is a method in the Microsoft.Visualbasic namespace that will do the trick. Just add a reference to Microsoft.VisualBasic and use the code above.