示例#1
0
 private void button5_Click(object sender, EventArgs e)
 {
     HandleClass6 h = new HandleClass6();
     Class9 c9 = new Class9();
     //Class6 parent = c7;
     //h.GetClass6String(parent);
     MessageBox.Show(h.GetClass6String(c9));
 }
示例#2
0
        private void button6_Click(object sender, EventArgs e)
        {
            HandleClass6 h = new HandleClass6();
            Class7 childObj = new Class7();

            Class6 parentPnt = childObj;

            MessageBox.Show(parentPnt.GetString()); // virtual
            MessageBox.Show(parentPnt.GetStringEx());
            
            
            
            ////父类变量指向之类的对象,上溯造型
            ////由父类变量实现的方法调用,如果该方法是虚方法,并且子类中实现override,那么
            ////调用的实际上就是子类方法。
            //Class6 newobj = new Class14();
            ////reflection
            ////MEF

            //MessageBox.Show(h.GetClass6String(newobj));//?

        }
示例#3
0
 private void button7_Click(object sender, EventArgs e)
 {
     HandleClass6 h = new HandleClass6();
     Class10 childObj = new Class10();
     MessageBox.Show(h.GetClass6String(childObj));//?
 }