How many bytes of memory does each type in .NET consume (32-bit environment)?

.net, c#, memory, memory-management

Solution

This page shows the size of each datatype in bits (divide by 8 to get bytes):

byte 8
sbyte 8
int 32
uint 32
short 16
ushort 16
etc...

Object and string are reference types. Reference types take up at least the size of all the fields they contain plus the size of the reference itself.

Related

- How big is an object reference in .NET?

Problem

How much memory in bytes do types like `int`, `bool`, `float`, `double`, `decimal`, `object`, and `string` use when added as a field to an instance of a class?

Original source

Related problems