在C#中,typeof是一個運算符,用于獲取一個類型的信息
using System;
class Program
{
static void Main()
{
// 使用 typeof 獲取 int 類型的Info
Type intType = typeof(int);
// 輸出 int 類型的名稱
Console.WriteLine("The type of int is: " + intType.Name);
}
}
在這個示例中,我們使用typeof運算符獲取了int類型的信息,并將其存儲在Type類型的變量intType中。然后,我們使用Name屬性輸出類型的名稱。