是否存在“严格”约束或强制执行可以使用的类型的方法。是否有严格执行可以使用的类型的方法。 (Very Explict Casting)
S <: T
喜欢的东西
Method(value As T) ' Any Type of T including subtypes of T
Method(value Is T) ' Only take a T not a subtype of T
我可以在运行时
If TypeOf value Is T Then
做到这一点但是,这是一个运行时检查,编译时检查会比较理想
Option Strict On
这只限制它(隐式)类型加宽Coerecions。
我想所有类型Coerecions必须明确。
可能吗?如果是这样如何?
你在做什么,子类型不能作为基本类型的有效替代(通常违反[Liskov Substitution Principle](http://en.wikipedia.org/wiki/Liskov_substitution_principle))?您的方案可能适用于[访问者]之类的模式(http://stackoverflow.com/questions/8828857/upcasting-helper-method/8830079#8830079)。 – 2012-02-20 15:43:01