当使用sizeof(int)时,需要调用print才能显示,输出为4,意味着int是4字节。
首先看一下sizeof在msdn上的定义:
The sizeof keyword gives the amount of storage, in bytes, associated
with a variable or a type (including aggregate types). This keyword
returns a value of type size_t.
查看sizeof发现返回的是一个结构体。
定义int a=6;
查看int的,才发现,原来int本来就是一个结构体。所以sizeof返回的是一个整型int。
namespace System
{
public struct Int32 : IComparable, IComparable<Int32>, IConvertible, IEquatable<Int32>, IFormattable
{
public const Int32 MaxValue = 2147483647;
public const Int32 MinValue = -2147483648;
public static Int32 Parse(string s, IFormatProvider provider);
public static Int32 Parse(string s, NumberStyles style, IFormatProvider provider);
public static