问题描述
过去几年我一直在使用C#进行编程,但现在我正在处理一个项目,我需要在VB.NET中编写所有代码。
我正在尝试用多个可重写的构造方法创建一个类。
问题是我不知道如何在VB.NET中定义一个构造函数,
更不用说继承默认的构造函数了。以下是我到目前为止:
公共类AppSnippets
私有_instances为整数
私有_appProcess As Process
私人_sysProcesses As Process()
Sub New()
Me._instances = 0
End Sub
Sub New(ByVal appProcess As Process)
MyBase.New()
Me._appProcess = appProcess
结束次级
结束班级
我真的不知道是否Sub New()是构造函数。如果是,我需要接受Process参数的
构造函数来首先调用之前的
构造函数。任何帮助和澄清将不胜感激。
carl
I''ve been programming exclusively in C# for the last few years but am now
working on a project where I am required to write all code in VB.NET.
I''m trying to create a class with multiple overrideable contructor methods.
The problem is that I don''t know how to even define a contructor in VB.NET,
let alone inherit the default contructor. Here is what I have so far:
Public Class AppSnippets
Private _instances As Integer
Private _appProcess As Process
Private _sysProcesses As Process()
Sub New()
Me._instances = 0
End Sub
Sub New(ByVal appProcess As Process)
MyBase.New()
Me._appProcess = appProcess
End Sub
End Class
I don''t really know if "Sub New()" is the constructor. If it is, I need the
constructor that accepts the Process parameter to call the previous
constructor first. Any help and clarification would be greatly appreciated.
carl
推荐答案
这篇关于覆盖/继承类构造方法...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!