14
Verifica del tipo: typeof, GetType o è?
Ho visto molte persone usare il seguente codice: Type t = typeof(obj1); if (t == typeof(int)) // Some code here Ma so che potresti anche fare questo: if (obj1.GetType() == typeof(int)) // Some code here O questo: if (obj1 is int) // Some code here Personalmente, penso che l'ultimo sia …