本文介绍了字符串对象之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有什么区别
what is the difference between
String s = "xyz";和
and
String s = new String("xyz");推荐答案
第二条语句不会编译.没有将字符串作为参数的String 构造函数(. msdn.microsoft/en-us/library/system.string.string.aspx [ ^ ]). The second statement won''t compile. There is no String constructor that takes a string as an argument (.msdn.microsoft/en-us/library/system.string.string.aspx[^]).
String代表System.String,它是.NET Framework类型. string是System.String的C#语言的别名.它们都被编译为IL(中间语言)中的System.String,因此没有区别.选择您喜欢的东西并使用它.如果您使用C#编写代码,则我更喜欢字符串,因为它是C#类型的别名,并且为C#程序员所熟知. 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
更多推荐
字符串对象之间的区别
发布评论