Constructors calling other constructors in vb.net a la c#
用C你可以
1 2 3 4 5 6 7 8 9 10 11 12 | public class Foo { public Foo(string name) { //do something } public Foo(string name, int bar) : this(name) { //do something } } |
有没有与vb.net相当的工具?
在这方面,它看起来与Java相似:
1 2 3 4 5 6 7 8 9 10 | Public Class Foo Public Sub New(name As String) ' Do something ' End Sub Public Sub New(name As String, bar As Integer) Me.New(name) ' Do something ' End Sub End Class |
注意,如果要调用基类的构造函数,必须使用