Tutorial :c# sizeof decimal?


Unclear on the sizeof for decimal types. Does the size in bytes vary by precision as in sql server? Is the precision variable for the c# type 'decimal'?

I don't want to turn on unsafe code to just call sizeof on a decimal type. How would you approach this?


As others have said, decimal is always 16 bytes (128 bits). The precision of decimal is always 28/29 digits. It's a floating point type, unlike SQL's DECIMAL type. See my article on it for more details.


The decimal keyword indicates a 128-bit data type.

Source: MSDN


The size of a System.Decimal in the .NET Framework is fixed at 16 Bytes.


128-bit precise decimal values with 28-29 significant digits, 128 bit = 16 byte

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »