String.Format vs string.Format. Any problems?

Are there any performance differences between the string. Formats and String.Format? As far as I understand, the string is a shortcut to System.String and there is no difference between them. I'm right?

Thanks!

+4
source share
5 answers

This is exactly the same. "string" is just an alias for "System.String" in C #

+13
source
Line

and String allow System.String. So there is no difference whatsoever.

+3
source

In c # line is just an alias for the CLR type System.String , so there is no performance difference. It is not clear why MS decided to include this alias, in particular, since other aliases (int, long, etc.) are value types, not reference types.

On my team, we decided that the static methods of the string class should be specified as, for example. String.ToUpper () , not string.ToUpper () to be more compatible with other CLR languages.

Ultimately, which version you use is up to you, but you must decide which one you will use in which context to improve consistency.

+2
source

Yes, the string is an alias for System.String in C #
Check it out yourself:

public static void Main(string[] args) { string s1 = "abc"; System.String s2 = "xyz"; Type t1 = s1.GetType(); Type t2 = s2.GetType(); System.Console.WriteLine( t1.Equals(t2) ); return ; } 
+1
source

Yes, there is no difference in terms of the CLR: string vs string - purely syntactic sugar C #.

+1
source

All Articles