• λ我爱Aspx >> Asp.Net >> 用NEW重新定义方法
  • 用NEW重新定义方法

  • :aspxer  Դ:csdn  :2007-7-6 2:50:29  ؼ:
  • google_ad_width = 250; google_ad_height = 250; google_ad_format = "250x250_as"; google_color_url = "000000";

    interface IStorable

    {

    void Read( );

    void Write( );

    }

    public class Document : IStorable

    {

    .........

    public void Write( )

    {

    Console.WriteLine(

    "Document Write Method for IStorable" );

    }

    }

    public class Note : Document

    {

    .........

    public new void Write( )

    {

    Console.WriteLine(

    "Implementing the Write method for Note!" );

    }

    }

    public class Tester

    {

    static void Main( )

    {

    // create a document reference to a Note object

    Document theNote = new Note( "Test Note" );

    这里Note类中的write方法,用了new以后是不是就算是一个全新的方法,和原来的IStorable接口没有关系,只能算是Note类的方法呢?

    Document theNote = new Note( "Test Note" );里面,theNote是Document的一个引用变量,它指向一个Note的对象,Note对象没有具体的名字,还只是一个内存中的地址,可以把theNote看作同时是Document和Note的对象吗,就像一个手里抓着两个气球?

    Ҷƪл˵?
  • һƪC#网络编程高手请进
    һƪ有关FCKeditor编辑器的问题!