14
Pengecekan Jenis: typeof, GetType, atau is?
Saya telah melihat banyak orang menggunakan kode berikut: Type t = typeof(obj1); if (t == typeof(int)) // Some code here Tapi saya tahu Anda juga bisa melakukan ini: if (obj1.GetType() == typeof(int)) // Some code here Atau ini: if (obj1 is int) // Some code here Secara pribadi, saya merasa …