This documentation is archived and is not being maintained.
Type::IsPrimitiveImpl Method
Visual Studio 2010
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 SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: