Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8426707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:36:13+00:00 2026-06-10T04:36:13+00:00

I understand this topic is answered a lot. My question is specific to the

  • 0

I understand this topic is answered a lot. My question is specific to the way it is said or asked.

So am I right to say, that code written with a class keyword will be on the managed heap and is a reference type, and code that is written with a struct will be on stack and is a value type?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T04:36:14+00:00Added an answer on June 10, 2026 at 4:36 am

    I used to think like this as well. However, I recently had a nice discussion with Jon Skeet (he may provide more details) and he explained me that a value type may be kept on the heap as well. The key is how long will that variable be used. If it’s a short-lived value type variable, it will be left only at the stack. However, if it’s used many times, the framework will keep it at the heap to save space at the stack.

    IMO, the key difference between reference and value types relies on passing the object to another object or method. If it’s a reference type, you are simply sharing its reference. If it’s a value type, then you are making a copy of it.

    About the subject of short x long-lived variable, here is the full picture:

    in the Microsoft implementation of C# on the desktop CLR, value types
    are stored on the stack when the value is a local variable or
    temporary that is not a closed-over local variable of a lambda or
    anonymous method, and the method body is not an iterator block, and
    the jitter chooses to not enregister the value.

    Source: The Truth About Value Types (it’s also on the comments)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'll start of by saying that I understand that this topic is complicated and
I understand that Android's developer site provides information on this topic. I have already
I understand that this question may seem somewhat ungrounded, but if someone knows anything
I know that there are a lot of questions about this topic, but unfortunately
I know this topic has already been asked here, but I don't understand why
i've read a few other post on here regarding this topic. I understand that
I understand that this question has been done to death so I'll apologise in
I have encountered this topic lately and couldn't understand why they are needed. Can
I understand this is an easy question but for some reason this just isn't
I understand this is a subjective question but I want to see how others

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.