How to determine the size of var?

  • A+
Category:Languages

I Have a variable declared as follows:

var a = 99494; 

Then I used the following to determine the size of the variable in bytes:

Marshal.SizeOf(a) 

Does it get the actual size of memory occupied by this value ?

 


Does it get the actual size of memory occupied by this value ?

Yes. In this case it is fairly simple, since the var is an int. It will always yield the same value (4). (var isn't a dynamic type, it is determined on compile time.)

Comment

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: