溫馨提示×

typeof c#如何使用typeof運算符

c#
小樊
115
2024-12-04 23:26:13
欄目: 編程語言

在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屬性輸出類型的名稱。

0
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女