The sizeof operator returns the number of bytes occupied by a given type of variable. The type of the operand specified as sizeof must be unmanaged.
From Version C #2.0, applying sizeof to built-in types does not require the use of the unsafe mode.
The sizeof operator cannot be overloaded. The Return Value of the sizeof operator is of the int type. The following table lists some constant values, which correspond to the sizeof expressions with some built-in types as operands.
For all other types (including structures), the sizeof operator can only be used in insecure code blocks. The result of the sizeof operator is defined by the implementation and belongs to the value rather than the constant.
When sizeof is applied to an operand with a structure type, the result is the total number of bytes occupied by this type of variable (including all fill bits ).
Although the marshal. sizeof method can be used, the value returned by this method is not always the same as the value returned by sizeof.
Inclual. sizeof returns the size after the mail type, while sizeof returns the size allocated during the Common Language Runtime (including all fills ).
C # basic keywords-sizeof Operator