继承之跨语言继承:inherit from C# to VB.net via CLR

 

' VB Code: which includes derived class. 
Imports System
Imports Donis.CSharpBook

Namespace Donis.CSharpBook
    Public Class Starter
        Public Shared Sub Main
            Dim child 
as New XChild
            child.MethodA()
            child.MethodB()
        End Sub
    End Class

    Public Class XChild
        Inherits XParent
        Public Sub MethodB
            Console.WriteLine(
"XChild.MethodB called from {0}.", _
                Me.GetType().ToString())
        End Sub
    End Class
End Namespace

// C# Code: which includes base class
using System;
namespace Donis.CSharpBook{
    
public class XParent {
        
public void MethodA() {
            Console.WriteLine(
"XParent.MethodA called from {0}.",
                
this.GetType().ToString());
        }
        
private int propFieldA;
        
public int FieldA {
            
get {
                    
return propFieldA;
            }

            
set {
                    propFieldA
=value;
            }
        }
    }
}

posted on 2007-10-08 10:09  lbq1221119  阅读(587)  评论(3编辑  收藏  举报

导航