开发者

How to check if a class implements an interface without navigating through its inheritance tree?

If I want to know if a class inherits IDisposable I have to Go To Definition in each of its parent classes and interfaces?

Isn'开发者_运维技巧t there an easier way?


Put an instance of the class in question in a using statement. The compiler will tell you if it is possible with that class or not.


If you have resharper installed, you can use type hierarchy (Crl + E, H) to view it quickly.


bool implementsIDisposable = (classInstance is IDisposable);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜