Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Format a String literal

Tags:

string

c#

.net

I want to format a string value by a certain format that the first letter of it be in Uppercase.
e.g:

string.Format("{0}", "myName"); //Output must be : "MyName"

How can I do it?

like image 578
Hamid62 Avatar asked Dec 11 '22 21:12

Hamid62


1 Answers

Please check MSDN for your case, see TextInfo.ToTitleCase Method .

string myString = "wAr aNd pEaCe";        
TextInfo myTI = new CultureInfo("en-US", false).TextInfo;
Console.WriteLine("\"{0}\" to titlecase: {1}", myString, myTI.ToTitleCase(myString));
like image 127
Uriil Avatar answered Jan 01 '23 21:01

Uriil