Feb 16 in C Sharp (C#)

What is the difference between a struct and a class in C#?

1 Answer

Feb 16

Class and struct both are the user defined data type but have some major difference:

** Struct**

The struct is value type in C-Sharp and it inherits from System.Value Type.

Struct is usually used for smaller amounts of data.

Struct can't be inherited to other type.

A structure can't be abstract.

No need to create object by new keyword.

Do not have permission to create any default constructor.


The class is reference type in C-Sharp and it inherits from the System.Object Type.

Classes are usually used for large amounts of data.

Classes can be inherited to other class.

A class can be abstract type.

We can't use an object of a class with using new keyword.

We can create a default constructor.

Click here to read more about C Sharp
Click here to read more about Insurance

Related questions

May 6 in C Sharp (C#)
Oct 18, 2019 in C Sharp (C#)
Apr 3 in Big Data | Hadoop