C# GetType() 方法用于获取当前对象的类型。它返回用于反射的 Type 类的实例。
public Type GetType()
它不带任何参数。
它返回 Type 类的对象。
using System; public class StringExample { public static void Main(string[] args) { string s1 = "Hello C#"; Console.WriteLine(s1.GetType()); } }
输出:
System.String