---
title: "What is the difference between a class and a structure?"  
description: "What is the difference between a class and a structure?"  
author: "Sumit Kesarwani"  
published: 2014-09-04  
updated: 2020-09-15  
canonical: https://www.mindstick.com/interview/2131/what-is-the-difference-between-a-class-and-a-structure  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# What is the difference between a class and a structure?

## Class:

A class is a reference type.

While instantiating a class, CLR allocates memory for its instance in heap.

Classes support inheritance.

Variables of a class can be assigned as null.

Class can contain constructor/destructor.

## Structure:

A structure is a value type.

In structure, memory is allocated on stack.

Structures do not support inheritance.

Structure members cannot have null values.

Structure does not require constructor/destructor and members can be initialiazed automatically.

## Answers

### Answer by Sumit Kesarwani

## Class:

A class is a reference type.

While instantiating a class, CLR allocates memory for its instance in heap.

Classes support inheritance.

Variables of a class can be assigned as null.

Class can contain constructor/destructor.

## Structure:

A structure is a value type.

In structure, memory is allocated on stack.

Structures do not support inheritance.

Structure members cannot have null values.

Structure does not require constructor/destructor and members can be initialiazed automatically.


---

Original Source: https://www.mindstick.com/interview/2131/what-is-the-difference-between-a-class-and-a-structure

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
