字符串对象之间的区别

编程入门 行业动态 更新时间:2024-10-24 19:13:49
本文介绍了字符串对象之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有什么区别

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

更多推荐

字符串对象之间的区别

本文发布于:2023-10-19 14:54:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1507856.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   区别   对象

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!