object nullobject = null;
object myobject = new myobject();
console.writeline("nullobject="+nullobject+"myobject="+myobject);
答案 0 :(得分:3)
它(不管怎样,对我而言)打印
nullobject=myobject=System.Object
(将= new myobject();
行更改为= new object();
并更正其他拼写错误。)
我不知道的事情(以及我很难发布这个的原因)是CSharp在连接时将空字符串对象视为空字符串。关于它,在这个页面的中间有一个注释。 http://msdn.microsoft.com/en-us/library/ms228504.aspx
object nullobject = null;
object myobject = new object();
Console.WriteLine(nullobject + ""); //ok, prints empty line
Console.WriteLine(nullobject.ToString()); //this will blow up
Console.WriteLine("nullobject=" + nullobject + "myobject=" + myobject); //ok, prints what's above.