1
 public class PersonClass
 {
        public string Name;
        public string Name1;
        public string Name2;
        public byte Age;
        public byte Age1;
        public byte Age2;
 }

I want know how much memory will be allocated on the stack if I will make such as assignment:

var newPerson = new PersonClass() // <- allocated new PersonsClass object
var pointer = newPerson // <- how match bytes will be allocated on stack?
2
  • 2
    Does this answer your question? stackoverflow.com/questions/3800882/…
    – canton7
    Commented Jan 16, 2020 at 14:13
  • 1
    What you have there is a reference type, not a value type, so far less is on the stack than you might think. This question touches on the size aspect beyond the reference, but see also Eric Lippert's "the stack is an implementation detail". There are many misconceptions programmers working in managed languages have when they port conventional wisdom from C-like languages, so the simple stack/heap dual model very often does not apply. Commented Jan 16, 2020 at 15:05

0

Browse other questions tagged or ask your own question.