C# Reference Type Variable

In this article i am explaining about reference type variable in C#. The Reference type variable is type of variable in C# that maintain the reference of memory address instead of value. class, interface, delegate, array is reference type. When you create object of any class with new keyword, a space is created in the managed heap that holds the reference of classes.

If you are use reference type variable as parameter, then you will have to use ref keyword with variable.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Reference_Parameter_Example
    class Program
        public static void Qube(ref int num)
            num = num * num * num;
        static void Main(string[] args)
            int original = 9;
            Console.Write("\nCurrent value of Original is {0}\t", original);
            Program.Qube(ref original);
            Console.WriteLine("\nNow the current value of Original is {0}\t", original);

Leave a Reply

Your email address will not be published. Required fields are marked *