---
title: "What is difference between Value types and Reference types in VB.NET or C# (Value types VS Reference types)?"  
description: "What is difference between Value types and Reference types in VB.NET or C# (Value types VS Reference types)?"  
author: "Amit Singh"  
published: 2010-11-16  
updated: 2020-09-20  
canonical: https://www.mindstick.com/interview/235/what-is-difference-between-value-types-and-reference-types-in-vb-dot-net-or-c-sharp-value-types-vs-reference-types  
category: "vb.net"  
tags: ["vb.net"]  
reading_time: 3 minutes  

---

# What is difference between Value types and Reference types in VB.NET or C# (Value types VS Reference types)?

C# provides two types—class and struct, class is a referencetype while the other is a value type. Here is difference between Value typesand Reference types.

Value types directly contain their data which are either allocated on the stackor allocated in-line in a structure. Reference types store a reference to thevalue's memory address, and are allocated on the heap. With reference types, anobject is created in memory, and then handled through a separate reference—ratherlike a pointer.

Reference types can be self-describing types, pointer types, or interfacetypes. Primitive types such as int, float, bool and char are value types.

**Variables** that are value types each have their own copy of the data, andtherefore operations on one variable do not affect other variables. Variablesthat are reference types can refer to the same object; therefore, operations onone variable can affect the same object referred to by another variable.

**Value types** have a default implied constructor that initializes the defaultvalue. Reference types default to a null reference in memory.

Value types derive from System.ValueType. Reference types derive fromSystem.Object.

Value types cannot derive a new type from an existing value type, except forstructs. Reference types can derive a new type from an existing reference typeas well as being able to implement interfaces.

## Answers

### Answer by Amit Singh

C# provides two types—class and struct, class is a referencetype while the other is a value type. Here is difference between Value typesand Reference types.

Value types directly contain their data which are either allocated on the stackor allocated in-line in a structure. Reference types store a reference to thevalue's memory address, and are allocated on the heap. With reference types, anobject is created in memory, and then handled through a separate reference—ratherlike a pointer.

Reference types can be self-describing types, pointer types, or interfacetypes. Primitive types such as int, float, bool and char are value types.

**Variables** that are value types each have their own copy of the data, andtherefore operations on one variable do not affect other variables. Variablesthat are reference types can refer to the same object; therefore, operations onone variable can affect the same object referred to by another variable.

**Value types** have a default implied constructor that initializes the defaultvalue. Reference types default to a null reference in memory.

Value types derive from System.ValueType. Reference types derive fromSystem.Object.

Value types cannot derive a new type from an existing value type, except forstructs. Reference types can derive a new type from an existing reference typeas well as being able to implement interfaces.


---

Original Source: https://www.mindstick.com/interview/235/what-is-difference-between-value-types-and-reference-types-in-vb-dot-net-or-c-sharp-value-types-vs-reference-types

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
