Table of Contents 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Notes DownloadECMA-334 C# Language Specification


25 Unsafe code
25.5 Pointers in expressions
25.5.8 The sizeof operator
Paragraph 11 The sizeof operator returns the number of bytes occupied by a variable of a given type. 2 The type specified as an operand to sizeof must be an unmanaged-type (§25.2). sizeof-expression : sizeof ( unmanaged-type )
Paragraph 21 The result of the sizeof operator is a value of type int. 2 For certain predefined types, the sizeof operator yields a constant value as shown in the table below.
| Expression |
Result |
| sizeof(sbyte) |
1 |
| sizeof(byte) |
1 |
| sizeof(short) |
2 |
| sizeof(ushort) |
2 |
| sizeof(int) |
4 |
| sizeof(uint) |
4 |
| sizeof(long) |
8 |
| sizeof(ulong) |
8 |
| sizeof(char) |
2 |
| sizeof(float) |
4 |
| sizeof(double) |
8 |
| sizeof(bool) |
1 |
Paragraph 31 For all other types, the result of the sizeof operator is implementation-defined and is classified as a value, not a constant.
Paragraph 41 The order in which members are packed into a struct is unspecified.
Paragraph 51 For alignment purposes, there may be unnamed padding at the beginning of a struct, within a struct, and at the end of the struct. 2 The contents of the bits used as padding are indeterminate.
Paragraph 61 When applied to an operand that has struct type, the result is the total number of bytes in a variable of that type, including any padding. |
| Jagger Software Ltd |
| Company # 4070126 |
| VAT # 762 5213 42 |

