c# - Struct on the heap? -



c# - Struct on the heap? -

this question has reply here:

does using “new” on struct allocate on heap or stack? 8 answers

so have this:

class simpledatestructuredemo { struct date { public int year; public int month; public int day; } static void main() { ... } }

and see example, saying object allocated on heap:

date datemoonwalk = new date();

i thought classes ref type, , structs value type. in end, can create struct type object on heap using new, right?

you can create struct type object on heap using new, right?

no, if within of main, in general, won't allocated on heap. can allocate struct on heap in many ways, though, including using field in class, using in closure, etc.

the new date syntax initializes struct it's default (zeroed out) value, doesn't alter how or it's allocated.

c# class struct stack heap

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -