Re: Boxing and Unboxing of Value-Types when passed to a method call
From: Bruce Wood (brucewood_at_canada.com)
Date: 01/24/05
- Next message: QAnders_Nor=E5s_=5BMCAD=5D=22?=: "Re: Compiler error with foreach?"
- Previous message: MarkT [developmentor]: "Re: Boxing and Unboxing of Value-Types when passed to a method cal"
- In reply to: ALI-R: "Re: Boxing and Unboxing of Value-Types when passed to a method call"
- Next in thread: ALI-R: "Re: Boxing and Unboxing of Value-Types when passed to a method call"
- Reply: ALI-R: "Re: Boxing and Unboxing of Value-Types when passed to a method call"
- Messages sorted by: [ date ] [ thread ]
Date: 24 Jan 2005 11:51:38 -0800
I believe that this would act the same as passing an int as int* in C.
To wit:
Whether there is heap space allocated depends very much on where the
"int a = 1355" appears. If it is a local variable in a method then it
will be on the stack; if it is a class member then it will allocated
within the class data area allocated on the heap; if it is a struct
member then it will be allocated within the struct data area either on
the stack or the heap, depending on whether the struct is a local
variable or a class member.
myMethod will be passed a pointer to (reference to) the memory location
at which the integer called "a" is stored. The pointer (reference) will
be allocated on the stack, because it is a method argument. Modifying b
within myMethod will modify a, because b and a refer to the same memory
location.
No boxing or unboxing involved; the reference passed to myMethod points
directly to the integer.
- Next message: QAnders_Nor=E5s_=5BMCAD=5D=22?=: "Re: Compiler error with foreach?"
- Previous message: MarkT [developmentor]: "Re: Boxing and Unboxing of Value-Types when passed to a method cal"
- In reply to: ALI-R: "Re: Boxing and Unboxing of Value-Types when passed to a method call"
- Next in thread: ALI-R: "Re: Boxing and Unboxing of Value-Types when passed to a method call"
- Reply: ALI-R: "Re: Boxing and Unboxing of Value-Types when passed to a method call"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|