When we assign int? a = null; It is memory allocated or not?

Posted by Karthik2010_Mca under Interview Questions on 4/14/2013 | Points: 10 | Views : 1115 | Status : [Member] | Replies : 2
Hi,

When we assign int? a = null; It is memory allocated or not?

When we assign int a = 10; // It is taken some memory.
When we assign int? a = null; // It is taken memory or not? also How to check?

Thanks
Karthik.K

Karthik


Responses

Posted by: Raj.Trivedi on: 4/14/2013 [Member] [MVP] Starter | Points: 25

Up
0
Down
Hello Karthik

When you assign a value to the variable it holds some memory and stored.

To release the memory after the work is done

you can do the following

int a = 10; // assigning memory

Now to check if int has memory

use this

if(int a !=null)
{
a = null;
}

this will release the memory


Regard's
Raj.Trivedi
"Sharing is Caring"
Please mark as answer if your Query is resolved

Karthik2010_Mca, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Learningtorise on: 4/15/2013 [Member] Starter | Points: 25

Up
0
Down
Memory is allocated and released as soon as execution goes out of its(variable's) scope.


http://hashtagakash.wordpress.com/

Karthik2010_Mca, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response