Mono Class Library: System.Type Overview | Members

System.Type.GetElementType Method

Returns the element type of the current Type .

public abstract Type GetElementType ()

Returns

A Type that represents the type used to create the current instance if the current instance represents an array, pointer, or an argument passed by reference. Otherwise, returns null if the current instance is not an array or a pointer, or is not passed by reference, or represents a generic type or a type parameter of a generic type or method.

Remarks

Documentation for this section has not yet been entered.

Example

The following example demonstrates the Type.GetElementType method.

C# Example

using System;
class TestType {
 public static void Main() {
 int[] array = {1,2,3};
 Type t = array.GetType();
 Type t2 = t.GetElementType();
 Console.WriteLine("{0} element type is {1}",array, t2.ToString());

 TestType newMe = new TestType();
 t = newMe.GetType();
 t2 = t.GetElementType();
 Console.WriteLine("{0} element type is {1}", newMe, t2==null? "null" : t2.ToString());
 }
}

The output is

System.Int32[] element type is System.Int32
TestType element type is null

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0