问题描述
Public MustInherit Class My3rdLevelClass
继承GeneratedClass
公共共享函数GetSomething()As String
返回Something
结束函数
在上面的示例中,我已将该类声明为MustInherit。
我对GetSomething方法的范围有疑问。
我可以直接从同一个项目的类中调用它。
应该设置什么才能允许继承它的类
使用它的能力。但这不允许任何人直接打电话给它?
-
Joe Fallon
Public MustInherit Class My3rdLevelClass
Inherits GeneratedClass
Public Shared Function GetSomething() As String
Return "Something"
End Function
In the sample above I have declared the class as MustInherit.
I have questions about the scope of the GetSomething method.
I was able to call it directly from a class in the same project.
What should it be set to in order to allow a class that inherits it the
ability to "use it" but that does not allow anyone to call it directly?
--
Joe Fallon
推荐答案
将其修饰符设置为''受保护''。
- -
Herfried K. Wagner
MVP·VB Classic,VB.NET
< http://www.mvps.org/dotnet> ;
Set its modifier to ''Protected''.
--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
这篇关于关于继承的另一个问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!