Is there a simple way to determine type size in C#?
        Posted  
        
            by archimedes
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by archimedes
        
        
        
        Published on 2008-12-12T18:34:12Z
        Indexed on 
            2010/04/16
            10:03 UTC
        
        
        Read the original article
        Hit count: 206
        
c#
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?
© Stack Overflow or respective owner