Is there a simple way to determine type size in C#?
- by archimedes
Is there a way to say something like:
sizeof(type)? Or type.Size?
Right now I am looking at using code like:
if (type.Equals(typeof(int)))
return sizeof(int);
else if (type.Equals(typeof(long)))
return sizeof(long);
etc, etc, for every single data type.
There must be an cleaner solution, no?