如何实现 Type. Is Primitive 属性 of Type in Net Standard 1.3

How to implement Type.​Is​Primitive Property of Type in Net Standard 1.3

我需要使用 Type. Is Primitive 属性 来检查当前类型是否是原始类型之一。我的目标是 Net Standard 1.3,因为它是某些将使用此包的项目中所需的 Net Standard 版本。如我所见 Dot Net API Documentation 此版本不支持它。我可以使用任何替代实现吗?还是一种确定类型是原始类型的方法?谢谢

你可以在netstandard1.3中使用type.GetTypeInfo().IsPrimitive。文档:https://docs.microsoft.com/en-us/dotnet/api/system.reflection.typeinfo.isprimitive?view=netstandard-1.3#System_Reflection_TypeInfo_IsPrimitive