Imports System Namespace VbLibrary Public Class Class1 Public F1 As New Class3(GetType(Class1).FullName) Public Sub New() Console.WriteLine("{0}.ctor()", GetType(Class1).FullName) End Sub End Class Public Class Class2 Inherits Class1 Public F2 As New Class3(GetType(Class2).FullName) Public Sub New() MyBase.New() Console.WriteLine("{0}.ctor()", GetType(Class2).FullName) End Sub End Class Public Class Class3 Public Sub New(ByVal s As String) Console.WriteLine("{0}.ctor({1})", Me.GetType().FullName, s) End Sub End Class End Namespace
using System; namespace CsLibrary { public class Class1 { public Class3 F1 = new Class3(typeof(Class1).FullName); public Class1 () { Console.WriteLine("{0}.ctor()", typeof(Class1).FullName); } } public class Class2 : Class1 { public Class3 F2 = new Class3(typeof(Class2).FullName); public Class2 () : base() { Console.WriteLine("{0}.ctor()", typeof(Class2).FullName); } } public class Class3 { public Class3 (string s) { Console.WriteLine("{0}.ctor({1})", this.GetType().FullName, s); } } }