ExtensionMethod.NET Home of 880 C#, Visual Basic, F# and Javascript extension methods

ToProperCase

Converts string to a title case.

Source

public static string ToProperCase(this string text)
{
	System.Globalization.CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture;
	System.Globalization.TextInfo textInfo = cultureInfo.TextInfo;
	return textInfo.ToTitleCase(text);
}

Example

string s = "tHiS is a sTring TesT";
Console.WriteLine("Title Case: {0}", s.ToProperCase());

// Output: This Is A String Test

Author: Earljon Hidalgo

Submitted on: 26 mrt. 2008

Language: C#

Type: System.String

Views: 11053