class A { this() { } }
class B : A { this() { } }
auto b = new B()
if(b.IsCastableTo(A)) {
//...
}
如何检查b是否可以转换为A型?
答案 0 :(得分:6)
根据D手册你会这样做:
if (cast(A) b) {
// b is an instance of A
} else {
// b is not an instance of A
}
<强>参考文献:强>