Type.GetElementType Method
Silverlight
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.
The following example demonstrates using the GetElementType method.
Note: |
|---|
To run this example, see Building Examples That Use a Demo Method and a TextBlock Control. |
using System; class Example { public static void Demo(System.Windows.Controls.TextBlock outputBlock) { int[] array = { 1, 2, 3 }; Type t = array.GetType(); Type t2 = t.GetElementType(); outputBlock.Text += String.Format("The element type of {0} is {1}.", array, t2.ToString()) + "\n"; Example newMe = new Example(); t = newMe.GetType(); t2 = t.GetElementType(); outputBlock.Text += String.Format("The element type of {0} is {1}.", newMe, t2 == null ? "null" : t2.ToString()) + "\n"; } } /* This code produces the following output: The element type of System.Int32[] is System.Int32. The element type of Example is null. */
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.
Note: