First char of string to upper case: what is more costly to the server? C# -


I have two ways to get the first letter of the string in the upper case, but I would like to know who uses more Server resource? (MVC 5, C #)

  string test1 = test.ToUpper () [0] + test.Substring (1);   

or

  string test1 = cultureInfo. Contentculture. TextInfo.ToTitleCase (test.ToLower ());    

Add it to your ExtensionMethods.cs

  Public Static Class Extension Cases {public static string uppercase suffix letter (string value) • The first letter uppercase in the string is called on this extension. // if (value.Length & gt; 0) {char [] array = value.ToCharArray (); Array [0] = char.ToUpper (array [0]); Return new string (array); } return value; }} According to   

: This is faster than your first method because it only assigns a new string in the return statement. The first method allocates two strokes: substrings (1), and then a new string with the string. Connaught.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -