Rajanikant Hawaldar
Why class is reference type?

Why class is reference type?

By Rajanikant Hawaldar in C# on Dec 18 2020
  • Kiran Mohanty
    Jan, 2021 4

    Let’s assume that class is a value type data. If so , when we instantiate it, some amount of memory would have been allocated in Stack. It would have been difficult for Garbage collector to identify non-referenced objects and hence leading to inefficient memory management.

    Since class is a reference type, GC handles memory management efficiently.

    This is just my opinion. There could be some other reason as well that i am not aware of now.

    • 6
  • Herbert Moroni
    Feb, 2021 17

    Because of a object created from a class is stored on a area in the memory called heap with only a reference to it on the stack memory.

    • 4
  • Rajeev Kumar
    Mar, 2023 17

    In C#, arguments can be passed to parameters either by value or by reference. Remember that C# types can be either reference types ( class ) or value types ( struct ): Pass by value means passing a copy of the variable to the method. Pass by reference means passing access to the variable to the method.

    • 0
  • Gnanasekaran P
    Feb, 2021 8

    When you write a method which is complext and need to split into muliple sub methods for readabilty purpose, you may have to pass the arugment by ‘Pass by reference’ to retain its functionlity.

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS