Possible duplicate:
How are managed memory descriptor types stored inside objects?
I have a class below
public class MyClass { public List<RequestRow> RequestRow { get; set; } public List<int> intList { get; set; } public string ErrorMessage { get; set; } public string SuccessMessage { get; set; } int i; DateTime dt = DataTime.Now; public void SomeMethod() {
The question is what will go into the heap and what is the stack? And why?
So, MyClass, properties, fields and method will go somewhere or onto the stack?
I recently found this question in an interview and I am interested to know about it.
Edited
I liked Mr. John, and my doubts were resolved.
I have 2 more questions to ask ...
a) When int, I and DateTime dt will be considered as a value type and will be pushed onto the stack
b) If I have an interface, say
namespace namespace1 { public interface IXLView { ExcelXP.Application ExcelApp { get; } ExcelXP.Workbook CurrentWorkBook { get; } ExcelVersion ExcelVersion { get; } } public enum ExcelVersion { Excel2003, Excel2007 } }
, then where will the objects be placed in this case .. Stack or Heap? Thanks
user372724
source share