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

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -