- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are the differences between a class and struct in C#?
Class
Class is a blueprint for a data type. A class definition starts with the keyword class followed by the class name.
Struct
A structure is a value type data type. It helps you to make a single variable hold related data of various data types. The struct keyword is used for creating a structure.
The following are the differences −
Classes are reference types and structs are value types
Structures do not support inheritance
Structures cannot have default constructor
When you create a struct object using the new operator, it gets created and the appropriate constructor is called. Unlike classes, structs can be instantiated without using the New operator.
Structures do not support inheritance
Structures cannot have default constructor
- Related Articles
- What are the differences between struct and class in C++?
- What are the differences between a class and a structure in C#?
- What are the differences between class methods and class members in C#?
- What are the differences between a static and a non-static class in C#?
- What are the differences between a class and an interface in Java?
- What are the differences between an Exception class and an Error class in Java?
- C/C++ Struct vs Class
- What are the differences between C++ and Java?
- What are the differences between C and Java?
- What are the differences between C++ and Go?
- What are the differences between constructors and destructors in C#?
- What are the differences between a dictionary and an array in C#?
- What are the differences between Thunderbolt and USB-C?
- Difference between 'struct' and 'typedef struct' in C++?
- What are the differences between bitwise and logical AND operators in C/C++

Advertisements