More about Virtual / new…plus interfaces!

前端 未结 6 874

Yesterday I posted a question about the new/virtual/override keywords, and i learned a lot from your answers. But still i remain with some doubts.

In between all the

6条回答
  •  伪装坚强ぢ
    2021-01-01 06:15

    In addition to other answers I am posting a correct answer:

                A a = new B();
                a.Draw(); //A::Draw
    
                I1 i1 = new A();
                i1.Draw(); //A::Draw
    
                I2 i2 = new B();
                i2.Draw();// B::Draw
    
                B b = (B) a;
                b.Draw();// B::Draw
    

提交回复
热议问题