var fileCount = Directory.EnumerateFiles(@"C:\").Count();
if (fileCount == 0)
Console.WriteLine("Empty");
else
Console.WriteLine("Not Empty");
您可以使用class a {/*code*/}
class b extends a {/*more code*/}
void main() {
b c = new b();
print(c.runtimeType == a); //type == inheritedType
//or
print(c.runtimeType inherits a); //operator for inheritance
//or
print(c inherits a); //other operator for inheritance
}
,type == inheriting type
或type inherits other type
吗?
有没有办法做这样的事情?
因为我还没有找到任何办法。
答案 0 :(得分:2)
使用is
。
你可以c is a
。请注意,new a() is a
也是true
。如果您真的想知道实例是否是另一种类型的子类型,您可能会问c is a && c.runtimeType != a
。