Re: Where are ref types that are members of value types stored?
- From: Jon Shemitz <jon@xxxxxxxxxxxxxxxxx>
- Date: Sun, 22 May 2005 11:59:29 -0700
> Structs are value types, strings are ref types. If you have something
> like this:
>
> struct foo
> {
>
> System.String str;
> }
>
> foo TheDayToday;
>
> then, where's
>
> TheDayToday.str
>
> going to be stored?
>
> (a) The string is going to be stored on the stack;
> (b) The struct is going to be stored on the stack with a 32-bit
> System.IntPtr/System.UInt32 also copied on the stack holding the
> address/reference to the actual string allocated on the heap.
(b) is the closest. The struct lives on the stack, and contains a
String reference, which will be 32-bit on a 32-bit system, and 64-bit
on a 64-bit system. The difference between "a 32-bit
System.IntPtr/System.UInt32" and "a String reference" is that the
system knows that "a String reference" points to a string, and will
update if the string is moved in GC.
--
www.midnightbeach.com
.
- Follow-Ups:
- Re: Where are ref types that are members of value types stored?
- From: Sathyaish
- Re: Where are ref types that are members of value types stored?
- References:
- Where are ref types that are members of value types stored?
- From: Sathyaish
- Where are ref types that are members of value types stored?
- Prev by Date: Where are ref types that are members of value types stored?
- Next by Date: Re: Where are ref types that are members of value types stored?
- Previous by thread: Where are ref types that are members of value types stored?
- Next by thread: Re: Where are ref types that are members of value types stored?
- Index(es):
Relevant Pages
|