In the 2nd case, you are actually creating 2 ints. i=10 is creating a new int 
(10) and assigning it to i, replacing the new int() it previously held.
Having said that, I believe the new int() was in the stack.
OTOH this would put it in the heap as it would be first created on the stack, 
then copied (boxed) to the heap due to the object reference:
object o = new int();




-----Original Message-----
From: "Girish Jain"<[EMAIL PROTECTED]>
Sent: 04/07/06 06:45:36
To: "[email protected]"<[email protected]>
Subject: Re: [ADVANCED-DOTNET] New Type decision Criterias

I was just going through the archive and found this...

> I think that, as the struct is allocated in the stack (if we don't use
> the "new" command to allocate it)

Just to confirm... I dont think if you use the new command, the value type
instance would be allocated on the heap..

int i = 10;

OR

int i = new int();
i = 10;

In both the above cases, i is allocated on the stack..

Let me know..if I am wrong.

Regards,
Girish Jain


----- Original Message -----
From: "Jean-Michel Reghem" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Thursday, January 12, 2006 7:20 PM
Subject: Re: [ADVANCED-DOTNET] New Type decision Criterias


> Paul Cowan wrote:
>> Than Jean-Michel.
>>
>> I did know that but in what scenario would I want to use the value
>> type over
>> the reference type.
>>
>> Are we strictly talking about performance.  Is this the only reason??
>> They
>> just seem like a quick and dirty class.
>>
> I think that, as the struct is allocated in the stack (if we don't use
> the "new" command to allocate it) , there is no garbage collector and
> thus, yes, it is done for performance ...
>
> ===================================
> This list is hosted by DevelopMentor®  http://www.develop.com
>
> View archives and manage your subscription(s) at
> http://discuss.develop.com
>

===================================
This list is hosted by DevelopMentor®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com





-----Unmodified Original Message-----
I was just going through the archive and found this...

> I think that, as the struct is allocated in the stack (if we don't use
> the "new" command to allocate it)

Just to confirm... I dont think if you use the new command, the value type
instance would be allocated on the heap..

int i = 10;

OR

int i = new int();
i = 10;

In both the above cases, i is allocated on the stack..

Let me know..if I am wrong.

Regards,
Girish Jain


----- Original Message -----
From: "Jean-Michel Reghem" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Thursday, January 12, 2006 7:20 PM
Subject: Re: [ADVANCED-DOTNET] New Type decision Criterias


> Paul Cowan wrote:
>> Than Jean-Michel.
>>
>> I did know that but in what scenario would I want to use the value
>> type over
>> the reference type.
>>
>> Are we strictly talking about performance.  Is this the only reason??
>> They
>> just seem like a quick and dirty class.
>>
> I think that, as the struct is allocated in the stack (if we don't use
> the "new" command to allocate it) , there is no garbage collector and
> thus, yes, it is done for performance ...
>
> ===================================
> This list is hosted by DevelopMentor®  http://www.develop.com
>
> View archives and manage your subscription(s) at
> http://discuss.develop.com
>

===================================
This list is hosted by DevelopMentor®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

===================================
This list is hosted by DevelopMentor�  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to