Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

Value Type vs. Reference Type#

Sumit Rawal answered on May 23, 2023 Popularity 8/10 Helpfulness 1/10

Contents


More Related Answers

  • what is out keyword in C# vs ref
  • c# field vs property
  • Primitive Type vs. Reference Type
  • Primitive Type vs. Reference Type
  • typedef vs #define
  • string is reference type in c#

  • Value Type vs. Reference Type#

    0

    To remain in the scope of this course, we won’t be getting into the nitty-gritty of the difference between value types and reference types. All you need to know is that for a value type, the information it provides is the value itself. For a reference type, the information it provides is a reference to some object, i.e., the memory address of an object. To make this clearer, let’s look at this using physical objects.

    svg viewer

    Imagine you have a piece of paper. You want the paper to hold some information, such as your name. You can write your name on the piece of paper; therefore the value of the paper is the same as the information it provides. This is an example of value type. If someone wants to know your name, all they have to do is read the paper.

    Now imagine, you want the paper to hold your house. That’s not physically possible, so you write the address to your house, hence the value of the paper is a reference to the required information. This is an example of reference type. If someone wants to go to your house, they will first have to read the directions to your house.

    In the same way, a reference type holds the memory address location of the value, while value types hold the value themselves.

    The focus of this chapter is value types.

    Popularity 8/10 Helpfulness 1/10 Language whatever
    Source: Grepper
    Link to this answer
    Share Copy Link
    Contributed on May 23 2023
    Sumit Rawal
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.