What is the difference between String and string in C#?

后端 未结 30 3911
走了就别回头了
走了就别回头了 2020-11-21 04:35

Example (note the case):

string s = \"Hello world!\";
String s = \"Hello world!\";

What are

30条回答
  •  悲哀的现实
    2020-11-21 05:29

    String stands for System.String and it is a .NET Framework type. string is an alias in the C# language for System.String. Both of them are compiled to System.String in IL (Intermediate Language), so there is no difference. Choose what you like and use that. If you code in C#, I'd prefer string as it's a C# type alias and well-known by C# programmers.

    I can say the same about (int, System.Int32) etc..

提交回复
热议问题