code_junkie

BaseType of a Basetype

Nov 11th, 2011
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. sim is MainSim;
  2. (sim as MainSim) != null;
  3. sim.GetType().IsSubclassOf(typeof(MainSim));
  4. typeof(MainSim).IsAssignableFrom(sim.GetType());
  5.  
  6. sim is MainSim;
  7. (sim as MainSim) != null;
  8. sim.GetType().IsSubclassOf(typeof(MainSim));
  9. typeof(MainSim).IsAssignableFrom(sim.GetType());
  10.  
  11. bool IsMainSimType(Type t)
  12. { if (t == typeof(MainSim)) return true;
  13. if (t == typeof(object) ) return false;
  14. return IsMainSimType(t.BaseType);
  15. }
  16.  
  17. if (sim is MainSim)
  18.  
  19. return t is MainSim;
Add Comment
Please, Sign In to add comment