What is the difference between "Class" and "Struct"? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

What is the difference between "Class" and "Struct"?

Declarations are the same. Both have fields and methods. You can make instance of them in the same way. Calling the members also is the same.

24th Aug 2020, 3:03 AM
Mosi B.
Mosi B. - avatar
5 Answers
+ 1
Quote: Structs are value types and are copied on assignment. Structs are value types while classes are reference types https://www.c-sharpcorner.com/blogs/difference-between-struct-and-class-in-c-sharp
24th Aug 2020, 12:04 PM
sneeze
sneeze - avatar
+ 4
The basic difference is that in structures, all the members are public by default whereas in class all are private by default.
24th Aug 2020, 4:08 AM
Arsenic
Arsenic - avatar
+ 1
sneeze Thanks 🙏🏻 The link you sent, made the point very clear to me. 👌🏻
24th Aug 2020, 12:46 PM
Mosi B.
Mosi B. - avatar
0
Arsenic just that?? So what's the point? Access modifiers easily can be changed manually. I don't think MS engineers define 2 different concepts just because of their access modifiers.
24th Aug 2020, 12:39 PM
Mosi B.
Mosi B. - avatar
0
Arsenic thats... C++ or c#?
24th Aug 2020, 5:20 PM
RpixPro
RpixPro - avatar