首页 新闻 赞助 找找看

接口调用的问题

0
悬赏园豆:5 [已解决问题] 解决于 2013-04-17 16:43

namespace Ch09Ex01{

    public abstract class MyBase{  }

    internal class MyClass : MyBase{}

    public interface IMyBaseInterface{}

    internal interface IMyBaseInterface2{}

    internal interface IMyInterface :IMyBaseInterface,IMyBaseInterface2{}

    internal sealed class MyComplexClass : MyClass,IMyInterface{}

class Program{

    static void Main(string[] args){

        MyComplexClass myObj = new MyComplexClass();

        Console.WriteLine(myObj.ToString());

        Consol.ReadKey();

    }

}

得出的结果:Ch09Ex01.MyComplexClass

为什么是这种结果?我不理解

lichen辰的主页 lichen辰 | 初学一级 | 园豆:196
提问于:2013-03-22 10:04
< >
分享
最佳答案
0

你可以鼠标移到ToString()这个方法上,就可以看到Returns a string that represents the current object. 用百度翻译就是"返回一个字符串,表示当前对象"。

收获园豆:5
beyondchina | 小虾三级 |园豆:680 | 2013-03-26 10:40
其他回答(1)
0

没看明白哪里不理解…

Firen | 园豆:5385 (大侠五级) | 2013-03-22 10:43

就不明白怎么输出的是:Ch09Ex01.MyComplexClass

Main()方法中调用的类中没有东西啊。只是用个myObj.ToString()就能输出这个结果吗?

支持(0) 反对(0) lichen辰 | 园豆:196 (初学一级) | 2013-03-22 10:47

@lichen辰: http://msdn.microsoft.com/zh-cn/library/9kkx3h3c(v=VS.80).aspx

Object.ToString()  就是返回类型名称。

支持(0) 反对(0) Firen | 园豆:5385 (大侠五级) | 2013-03-22 13:07
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册