Type.GetElementType Method
.NET Framework 4.5
When overridden in a derived class, returns the Type of the object encompassed or referred to by the current array, pointer or reference type.
Namespace: System
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 null 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 System; class TestGetElementType { public static void Main() { int[] array = {1,2,3}; Type t = array.GetType(); Type t2 = t.GetElementType(); Console.WriteLine("The element type of {0} is {1}.",array, t2.ToString()); TestGetElementType newMe = new TestGetElementType(); t = newMe.GetType(); t2 = t.GetElementType(); Console.WriteLine("The element type of {0} is {1}.", newMe, t2==null? "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 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.