Dans le développement web il est souvent utile de pouvoir capitaliser du texte. Le Framework .NET nous fourni une méthode assez bien cachée de la classe CultureInfo.
MSDN
CultureInfo Class
Provides information about a specific culture (called a "locale" for unmanaged code development). The information includes the names for the culture, the writing system, the calendar used, and formatting for dates and sort strings.
Namespace: System.Globalization
Assembly: mscorlib (in mscorlib.dll)
Une petite transformation en extension de méthode et le tour est joué !
public static String Capitalize(this String s)
{
return CultureInfo.CurrentCulture.TextInfo.ToTitleCase(s);
}
A Bientôt :)
f09ece0b-45e0-4bc9-8ce0-a94cb6bc778c|0|.0
C#
c#, extensions