When you get Type of the variable you can check its name:
if (my_type.Name=="Int32")
however it would more elegant to write
if (my_type.Name==TypeNames.Int32)
to avoid typos. I can define such class on my own, but maybe there is already definition somewhere?
If yes, where?
Note: please avoid wondering “why would you like to get type of the variable in the first place”, “it is better to use ‘is'” and alike. Thank you very much!
Edit: meanwhile, I jumped into the conclusion it would be enough to ignore the type of the object (my_type variable) and check the object instead. In other words the my_type is not necessary. I forgot about null case 🙁 Less code, more sleep, that’s what I need 😉
Try the following
If you want to compare types though doing so by name is not the best solution as it will be wrong in many cases. It’s more correct to compare the types directly.