Type::GetElementType Method
When overridden in a derived class, returns the Type of the object encompassed or referred to by the current array, pointer or reference type.
Assembly: mscorlib (in mscorlib.dll)
Return Value
Type: System::TypeThe Type of the object encompassed or referred to by the current array, pointer, or reference type, or nullptr if the current Type is not an array or a pointer, or is not passed by reference, or represents a generic type or a type parameter in the definition of a generic type or generic method.
Implements
_Type::GetElementType()The following example demonstrates using the GetElementType method.
using namespace System; public ref class TestGetElementType{}; int main() { array<Int32>^array = {1,2,3}; Type^ t = array->GetType(); Type^ t2 = t->GetElementType(); Console::WriteLine( "The element type of {0} is {1}.", array, t2 ); TestGetElementType^ newMe = gcnew TestGetElementType; t = newMe->GetType(); t2 = t->GetElementType(); Console::WriteLine( "The element type of {0} is {1}.", newMe, t2 == nullptr ? "null" : t2->ToString() ); } /* This code produces the following output: The element type of System.Int32[] is System.Int32. The element type of TestGetElementType is null. */
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.