Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. what is a C# reference type

what is a C# reference type

Scheduled Pinned Locked Moved C#
csharpquestionc++learning
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    misha_grewal
    wrote on last edited by
    #1

    I just started learning .Net and C#. I come from C++ background. When I declare a class vble // class A is defined; A a; a = new A(); This object a is allocated in heap right? and its a reference type? It seams all class variables are reference types. And it looks like a class pointer to me when I relate to C++. Any good article? thanks, Misha Evil traiumphs when good people sit quiet...

    L G 2 Replies Last reply
    0
    • M misha_grewal

      I just started learning .Net and C#. I come from C++ background. When I declare a class vble // class A is defined; A a; a = new A(); This object a is allocated in heap right? and its a reference type? It seams all class variables are reference types. And it looks like a class pointer to me when I relate to C++. Any good article? thanks, Misha Evil traiumphs when good people sit quiet...

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      JFGI[^]

      1 Reply Last reply
      0
      • M misha_grewal

        I just started learning .Net and C#. I come from C++ background. When I declare a class vble // class A is defined; A a; a = new A(); This object a is allocated in heap right? and its a reference type? It seams all class variables are reference types. And it looks like a class pointer to me when I relate to C++. Any good article? thanks, Misha Evil traiumphs when good people sit quiet...

        G Offline
        G Offline
        Guffa
        wrote on last edited by
        #3

        misha_grewal wrote:

        This object a is allocated in heap right? and its a reference type?

        Correct.

        It seams all class variables are reference types.

        That's right. A class is always a reference type, and a struct is always a value type.

        And it looks like a class pointer to me when I relate to C++.

        A reference is implemented as a pointer, but it's easier to use in the code. You don't have to dereference a reference to get to the object, as you do with a pointer.

        --- single minded; short sighted; long gone;

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups