Possible Duplicate:
Fields of class, are they stored in the stack or heap?
I was reading some article about Stack vs Heap (just to refresh my knowledge).
Far as I know, if I create a value type inside a reference type (a class), the value type will also be stored in the Heap. Because where the value type being store is depends on where its created.
But then, when we create our application (say WPF/Silverlight), when we create our UserControl, ViewModel, isn't they are also a class (an object) a reference type?
So I kind of wonder, so no matter what I creates inside the UserControl and ViewModel will also be in Heap?
So I kind of wonder, so no matter what I creates inside the UserControl and ViewModel will also be in Heap?
Yes, this is true. The UserControl
is a class, so the memory for it, and any variables within it, it will be stored on the heap.
There are two things here: