---
title: "Difference Between Class and Structure in C#"  
description: "There are many differences between class and structure as below:  1 A class is a group of objects that has common properties and it is a template or b"  
author: "Anupam Mishra"  
published: 2015-12-16  
updated: 2018-03-13  
canonical: https://www.mindstick.com/blog/10996/difference-between-class-and-structure-in-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# Difference Between Class and Structure in C#

##### There are many differences between class and structure as below:

## \

1 A class is a group of objects that has common [properties](https://www.mindstick.com/articles/23331/nootropics-7-different-types-and-their-unique-properties) and it is a template or blueprint from which objects are created.But in [structure](https://www.mindstick.com/articles/23258/choose-your-business-structure-wisely), it is a value type datatype that helps you to make a single [variables](https://www.mindstick.com/articles/715/php-variables) hold [related data](https://www.mindstick.com/interview/22990/what-is-lazy-eager-and-explicit-loading-of-related-data-in-entity-frameworks) of various datatype.

2 In class you can define constructor [as well as](https://www.mindstick.com/interview/2481/can-you-write-a-java-class-that-could-be-used-both-as-an-applet-as-well-as-an-application) destructor.But in structure, you cannot define [default constructor](https://www.mindstick.com/forum/34531/default-constructor) (it’s created automatically when you create structure instance. Instead of default you can use parameterized constructor in structure) and destructor are not allowed here.\

3 In class you can use [inheritance](https://www.mindstick.com/articles/13095/inheritance-and-its-types) but in structure you don’t inherit other structure.

4 In class, you can implement more than one [interfaces](https://www.mindstick.com/articles/12100/interfaces-in-java-real-life-example) as same as in structure.

5 In structure member can’t be specifies as abstract virtual or [protected access](https://www.mindstick.com/forum/156707/what-is-the-difference-between-public-private-and-protected-access-modifiers) specifier. But in class you can does.

6 In class only static member and member [function](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server) are no need to depend upon class instances.But in structure if you are not using new keyword then the field remained unassigned & the object can’t be used until all the fields are initialized.

##### Syntax of Structure:

```
struct Student{private string name;……………………//defining members or methods};
```

##### Syntax of class:

```
<Access Specifier > class <Class_Name>{// Member variables<Access Specifier><data type> var1;<Access Specifier><data type> var1;……………………………………….//Defining default Constructor Public <Class_Name>(){        //default constructor invoked                                 }    // defining parameterized constructor Public <Class_Name>(<data type varn>){        //parameterized  constructor invoked           }//destructor declaration~<Class_Name>(){       //Destructor is invoked                          }//method declaration    <Access Specifier><return type>Method1(parameter_list)        {    //Method body        }//defining main for starting execution or entry pointstatic void main(string[] args){// creating instance of class & automatically called default constructor itself<Class_Name> ob1=new <Class_Name>();//for calling parameterized constructor <Class_Name> ob2=new <Class_Name>(<data type var1>);//calling static methodsMethod1(<data type var1>);//waiting for pressing keysConsole.Readkey();}}
```

---

Original Source: https://www.mindstick.com/blog/10996/difference-between-class-and-structure-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
