คำถามในหัวข้อ 'gettype'

การตรวจสอบประเภท: typeof, GetType หรือเป็น?
ฉันเคยเห็นคนจำนวนมากใช้รหัสต่อไปนี้: Type t = typeof(obj1); if (t == typeof(int)) // Some code here แต่ฉันรู้ว่าคุณก็ทำสิ่งนี้ได้เช่นกัน: if (obj1.GetType() == typeof(int)) // Some code here หรือสิ่งนี้: if (obj1 is int)...
1151355 มุมมอง
schedule 01.12.2023