© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
9 replies
salty_pepper

Reference type variables themselves are stored on the stack, is that correct?

While we often say value types live on the stack, ref types live on the heap.

That's not completely true right?

1. eg. Building house = new Building();

In this case, house is simply a pointer to the building object. And it's stored on the stack. While actual building object is stored on the heap.

2. When we assign int to a List<int>, those int values actually live on the heap. ( Of course if we create int variables directly, they are stored on the stack)

Is this the correct interpretation?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ reference type values are strange..
C#CC# / help
4y ago
Expressing intent that method parameters are immutable for reference type arguments
C#CC# / help
3y ago
CS00012 The type is defined in an assembly that is not referenced. But that assembly it is reference
C#CC# / help
3y ago
How the cache is stored
C#CC# / help
4y ago