How do I determine if System.Type is a custom type or a Framework type?

前端 未结 5 894
情书的邮戳
情书的邮戳 2020-12-17 17:45

I want to distinctly determine if the type that I have is of custom class type (MyClass) or one provided by the Framework (System.String).

Is there any way in refle

5条回答
  •  孤城傲影
    2020-12-17 18:17

    Check if the assembly belongs to the CLR library:

    myType.Module.ScopeName == "CommonLanguageRuntimeLibrary"
    

    as explained here.

提交回复
热议问题