Value Types & Reference Types In C Sharp

In this article we will learn about Value Types and Reference Type in c sharp

Value Types: 

Value Types can be assigned directly. It is store in the memory  allocated on the stack .

Example :

We have declared a int variable named number and assigned value 10. Then Change method has been created with  a parameter which is int type. Again number variable has been assigned in change method which is 20. At last we have tried to show number variable in command mode. output is 10

Bellow is the list of value types :

  • bool
  • byte
  • char
  • decimal
  • double
  • enum
  • float
  • int
  • long
  • sbyte
  • short
  • struct
  • uint
  • ulong
  • ushort

Reference Types:

The reference types do not contain the actual data stored in a variable, but they contain a reference to the variables. It is store in the memory allocated on the heap


Student Class

Program Class




Bellow is the list of value types :

  • class
  • interface
  • delegate
  • object
  • string

Leave a Reply

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