Type.GetElementType 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
파생 클래스에서 재정의되는 경우 현재 배열, 포인터 또는 참조 형식에서 포함하거나 참조하는 개체의 Type 반환합니다.
public:
abstract Type ^ GetElementType();
public abstract Type GetElementType();
public abstract Type? GetElementType();
abstract member GetElementType : unit -> Type
Public MustOverride Function GetElementType () As Type
반품
Type 현재 배열, 포인터 또는 참조 형식이 포함하거나 참조하는 개체이거나null, 현재 Type 가 배열이나 포인터가 아니거나, 참조로 전달되지 않거나, 제네릭 형식 또는 제네릭 메서드의 정의에서 제네릭 형식 또는 형식 매개 변수를 나타내는 경우입니다.
구현
예제
다음 예제에서는 메서드를 사용하는 방법을 보여 줍니다 GetElementType .
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.
*/
type TestGetElementType() = class end
do
let array = [| 1; 2; 3 |]
let t = array.GetType()
let t2 = t.GetElementType()
printfn $"The element type of {array} is {t2}."
let newMe = TestGetElementType()
let t = newMe.GetType()
let t2 = t.GetElementType()
printfn $"""The element type of {newMe} is {if t2 = null then "null" else string t2}."""
(* This code produces the following output:
The element type of System.Int32[] is System.Int32.
The element type of TestGetElementType is null.
*)
Class TestGetElementType
Public Shared Sub Main()
Dim array As Integer() = {1, 2, 3}
Dim t As Type = array.GetType()
Dim t2 As Type = t.GetElementType()
Console.WriteLine("The element type of {0} is {1}.", array, t2.ToString())
Dim newMe As New TestGetElementType()
t = newMe.GetType()
t2 = t.GetElementType()
If t2 Is Nothing Then
Console.WriteLine("The element type of {0} is {1}.", newMe, "null")
Else
Console.WriteLine("The element type of {0} is {1}.", newMe, t2.ToString())
End If
End Sub
End Class
' This code produces the following output:
'
'The element type of System.Int32[] is System.Int32.
'The element type of TestGetElementType is null.
설명
이 메서드는 클래스에 대해 반환 null 합니다 Array .