Memory allocation for class objects in .Net

This is a very good interview question.

Assume a class

public class ABC

{

Public int MyInt;

}

Now where the memory for object of ABC is allocated and where the memory for MyInt variable is allocated?

Ofcourse the answer is memory to class object and its members are allocated on heap.

However few scenario to fine tune this answer please do read this post:

http://stackoverflow.com/questions/4487289/memory-allocation-stack-vs-heap

Advertisements

One thought on “Memory allocation for class objects in .Net

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s