- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Value Type vs Reference Type in C#
Value Type and Reference, both are types in C# −
Value type variables can be assigned a value directly. They are derived from the class System.ValueType. The value types directly contain data. When you declare an int type, the system allocates memory to store the value.
Value Type variables are stored in the stack.
Examples are int, char, and float, which stores numbers, alphabets, and floating point numbers, respectively.
It refers to a memory location. Using multiple variables, the reference types can refer to a memory location. If the data in the memory location is changed by one of the variables, the other variable automatically reflects this change in value.
Reference Type variables are stored in the heap.
Example of built-in reference types are −
- SAP ABAP: Using Elementary data type and reference type with keyword VALUE
- Pass by reference vs value in Python
- Value parameters vs Reference parameters vs Output Parameters in C#
- Pass by reference vs Pass by Value in java
- Type difference of character literals in C vs C++
- Change input type value attribute in jQuery
- What is a reference/ref parameter of an array type in C#?
- Input type DateTime Value format with HTML
- Difference Between Type casting and Type Conversion
- Get the TypeCode for value type Char in C#
- Get the TypeCode for value type Decimal in C#
- Get the TypeCode for value type Int32 in C#
- Get the TypeCode for value type UInt64 in C#
- Get the TypeCode for value type UInt32 in C#