Determine if a type is static

前端 未结 5 765
梦谈多话
梦谈多话 2020-11-29 08:49

Let\'s say I have a Type called type.

I want to determine if I can do this with my type (without actually doing this to each type):

5条回答
  •  心在旅途
    2020-11-29 09:39

    type.IsAbstract && type.IsSealed
    

    This would be a sufficient check for C# since an abstract class cannot be sealed or static in C#. However, you'll need to be careful when dealing with CLR types from other languages.

提交回复
热议问题