Type::IsPrimitiveImpl Method
When overridden in a derived class, implements the IsPrimitive property and determines whether the Type is one of the primitive types.
Assembly: mscorlib (in mscorlib.dll)
The following example determines whether the given type is a primitive type and displays the result.
using namespace System; using namespace System::Reflection; public ref class MyTypeDelegatorClass: public TypeDelegator { public: String^ myElementType; private: Type^ myType; public: MyTypeDelegatorClass( Type^ myType ) : TypeDelegator( myType ) { this->myType = myType; } protected: // Override the IsPrimitiveImpl. virtual bool IsPrimitiveImpl() override { // Determine whether the type is a primitive type. if ( myType->IsPrimitive ) { myElementType = "primitive"; return true; } return false; } }; int main() { try { Console::WriteLine( "Determine whether int is a primitive type." ); MyTypeDelegatorClass^ myType; myType = gcnew MyTypeDelegatorClass( int::typeid ); // Determine whether int is a primitive type. if ( myType->IsPrimitive ) { Console::WriteLine( "{0} is a primitive type.", int::typeid ); } else { Console::WriteLine( "{0} is not a primitive type.", int::typeid ); } Console::WriteLine( "\nDetermine whether String is a primitive type." ); myType = gcnew MyTypeDelegatorClass( String::typeid ); // Determine if String is a primitive type. if ( myType->IsPrimitive ) { Console::WriteLine( "{0} is a primitive type.", String::typeid ); } else { Console::WriteLine( "{0} is not a primitive type.", String::typeid ); } } catch ( Exception^ e ) { Console::WriteLine( "Exception: {0}", e->Message ); } }
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.