c# - Can reference types be allocated on stack? -
consider following code:
class point { public int position; }
here int position allocated on heap if value type.
but question opposite scenario,consider following code:
struct person { public string name; }
here string name allocated on heap or stack?
tia
no. reference string allocated ever person allocated. string allocated on heap. infact everytime new t t class object allocated on heap.
Comments
Post a Comment