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

UppercaseFirstLetter

Upper case first letter

Source

public static string UppercaseFirstLetter(this string value)
{
	//
	// Uppercase the first letter in the string.
	//
	if (value.Length > 0)
	{
	    char[] array = value.ToCharArray();
	    array[0] = char.ToUpper(array[0]);
	    return new string(array);
	}
	return value;
}

Example

string value = "dot net perls";
value = value.UppercaseFirstLetter();

//Return "Dot net perls"

Author: Luã Govinda

Submitted on: 11 jun 2015

Language: C#

Type: C#

Views: 2378