---
title: "c# - Difference between class and structure."  
description: "c# - Difference between class and structure."  
author: "Anonymous User"  
published: 2016-05-05  
updated: 2020-09-17  
canonical: https://www.mindstick.com/interview/23015/c-sharp-difference-between-class-and-structure  
category: "c#"  
tags: ["c#", "oops"]  
reading_time: 2 minutes  

---

# c# - Difference between class and structure.

1. Classes are usually used for large amounts of data, whereas structs are usually used for smaller amounts of data.

2. Classes can be inherited whereas structures not.

3. A structure couldn't have a destructor such as a class.

4. A structure can't be abstract, a class can.

5. A structure must always have the default parameter less constructor defined as public but a class might have one, so you can't define a private parameter-less constructor as in the following:

6. Class is a reference type and its object is created on the heap memory, whereas structure is a value type that is why its object is created on the stack memory.

7. Class can inherit another class, whereas structure does not support the inheritance.

8. Class object cannot be created without using the new keyword; it means we have to use it. Demo obj=new Demo();

whereas structure object can be created without using the new keyword.(optional) Demo obj;

## Answers

### Answer by Anonymous User

1. Classes are usually used for large amounts of data, whereas structs are usually used for smaller amounts of data.

2. Classes can be inherited whereas structures not.

3. A structure couldn't have a destructor such as a class.

4. A structure can't be abstract, a class can.

5. A structure must always have the default parameter less constructor defined as public but a class might have one, so you can't define a private parameter-less constructor as in the following:

6. Class is a reference type and its object is created on the heap memory, whereas structure is a value type that is why its object is created on the stack memory.

7. Class can inherit another class, whereas structure does not support the inheritance.

8. Class object cannot be created without using the new keyword; it means we have to use it. Demo obj=new Demo();

whereas structure object can be created without using the new keyword.(optional) Demo obj;


---

Original Source: https://www.mindstick.com/interview/23015/c-sharp-difference-between-class-and-structure

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
