可能调用ToString只是表面现象,但实验结果是如此在object和string中都没找到对运算符“+”的重写,也没有相关的implicit explicit的定义,怎么从主义上理解这样的用法呢?
string a = "abc";
Type b = a.GetType();
string c = a + b;
string d = b + a;
string a = "abc";
Type b = a.GetType();
string c = a + b;
string d = b + a;
解决方案 »
- 求助 救命啊~~~~ 网上租了个MSSql 数据库
- 求一数据处理的SQL
- 关于利用反射setvalue()方法给combobox控件赋值失败的问题
- WPF关于CollectionViewSource.View
- Button上文字的怪问题,真正的高手请进!
- 怎么样才能关掉新窗体的进程?菜鸟求助!
- 有关C#文件读写的问题
- web Service同步问题,请高手指教
- static void Main()能调用同一类中的方法吗?
- 哪位还在利用免费的SMTP服务器用.net发信,好像gmail、网易、QQ都禁止使用SMTP了,怎么办啊
- 编程中的错误
- 设置dropdownlist宽度但内容长度长于下拉框宽度内容要显示完全
object)
发现,编译后,是调用String对象的Concat方法,然后反编译查看Concat方法的代码,相关代码如下:public static String Concat(params Object[] args) {
if (args==null) {
throw new ArgumentNullException("args");
}
Contract.Ensures(Contract.Result<String>() != null);
Contract.EndContractBlock(); String[] sArgs = new String[args.Length];
int totalLength=0; for (int i=0; i<args.Length; i++) {
object value = args[i];
sArgs[i] = ((value==null)?(String.Empty):(value.ToString()));
if (sArgs[i] == null) sArgs[i] = String.Empty; // value.ToString() above could have returned null
totalLength += sArgs[i].Length;
// check for overflow
if (totalLength < 0) {
throw new OutOfMemoryException();
}
}
return ConcatArray(sArgs, totalLength);
}
可以看出,FCL程序,是将个对象的ToString结果存入预处理数组中
而是类似于&,|这样的操作符