Type.GetElementType() 方法在 C# 中
C# 中的 Type.GetElementType() 方法用于返回当前数组、指针或引用类型所包含或引用的对象的类型。
语法
以下是语法 −
public abstract Type GetElementType ();
示例
现在让我们看一个示例来实现 Type.GetElementType() 方法 −
using System;
public class Demo {
public static void Main(){
string[] arr = {"tom", "amit", "kevin", "katie"};
Type t1 = arr.GetType();
Type t2 = t1.GetElementType();
Console.WriteLine("Type = "+t2.ToString());
}
}输出
这将产生以下输出 −
Type = System.String
示例
现在让我们看另一个示例来实现 Type.GetElementType() 方法 −
using System;
public class Demo {
public static void Main(){
Type t1 = typeof(int[,,,, ]);
Type t2 = t1.GetElementType();
Console.WriteLine("Type = "+t2.ToString());
}
}输出
这将产生以下输出 −
Type = System.Int32
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP