Possible Duplicate:
How does .net managed memory handle value types inside objects?
I have a class as 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()
{
//some operation
}
}
The question is Which will go to heap and which to stack? And why?
Means MyClass , the properties, fields, and the method will go where..heap or stack?
Recently I found this question in an interview and is curious to know about this
Edited
I liked Mr.John's answer and my doubts have been cleared..
I have 2 more questions to ask...
a) When will int i and DateTime dt be treated as Value type and will be put into 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 be the objects be placed in this case..Stack or Heap? Thanks