字符串问题........... [英] String Question ...........

查看:67
本文介绍了字符串问题...........的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么区别

 字符串 s =   测试; 

字符串 s = new 字符串 测试);

解决方案

区别在于第一个编译,但第二个没有编译。它给出了这个错误:

Quote:

'string.String(char *)'的最佳重载方法匹配有一些无效的参数



为什么?因为 String 的构造函数不接受字符串作为参数。你可以在这里找到一个过载列表:

http:// msdn.microsoft.com/en-us/library/system.string.string.aspx [ ^ ]


 字符串 s =  测试; 
// 这会将值Test设置为字符串变量

字符串 sData = new 字符串 测试);
// 这会产生这样的错误..
// 'string.String(char *)'的最佳重载方法匹配有一些无效的参数 < /跨度>


what is difference between

String s = "Test";

String s = new String("Test");

解决方案

The difference is that the first does compile, but the second does not. It gives this error:

Quote:

The best overloaded method match for 'string.String(char*)' has some invalid arguments


Why? Because the constructor of String does not take a string as argument. You can find an overload list here:
http://msdn.microsoft.com/en-us/library/system.string.string.aspx[^]


  String s = "Test";
  //This Will Set value "Test" into string variable

   String sData = new String("Test");
   //This will give an error like this..
//The best overloaded method match for 'string.String(char*)' has some invalid arguments


这篇关于字符串问题...........的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆