返回继承另一个类的任何类 [英] Return any class which inherits another class
本文介绍了返回继承另一个类的任何类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我有一个基类CodeElement和多个继承CodeElement的类。
我怎么能有一个函数返回(任何继承CodeElement的东西)?
我尝试过:
搜索有关继承的内容
解决方案
将方法声明为返回基类的实例:
公共函数MyMethod()As CodeElement
...
结束函数然后它可以返回从CodeElement派生的任何值
Hi
I have a base class CodeElement and multiple classes which inherit CodeElement.
How can I have a function returning (anything which inherits CodeElement)?
What I have tried:
Searching for a while about inheritance解决方案Declare the method as returning an instance of the base class:
Public Function MyMethod() As CodeElement ... End FunctionIt can then return any value which is derived from CodeElement
这篇关于返回继承另一个类的任何类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文