首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 編程語言 >  >> C語言 >> 關於C語言

C# 與 VB.NET 型別系統整理(一):GetType 方法與運算子的多重含義

     編輯:關於C語言

Object.GetType()

所有物件皆有,回傳執行時確切型別的 Type 實例。

// C#
int n = 3;
Type t = n.GetType(); // System.Int32

// VB
Dim n As Integer = 3
Dim t As Type = n.GetType() ' System.Int32

VB GetType 運算子

Dim t As Type = GetType(Integer) ' 等同 C# typeof(int)

Type.GetType 靜態方法

// C#
Type t = Type.GetType("System.Int32");

// VB
Dim t As Type = Type.GetType("System.Int32")

參數必須為完整型別名稱(含命名空間),非 C# int 或 VB Integer 關鍵字。

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved