What is the Difference between a struct in C# and C++?

Published on Sunday, May 5, 2019

What is the difference between a Struct in C# and C++?

The main difference between Struct in C# and C++ is that a Struct in C# is a Value Type but it is a Reference Type in C++.

A Struct is almost the same as a Class in C++, but just its members are public by default, Class members are private by default.

A Struct in C++ can be inherited, just like a Class; But a Struct in C# can not derive. A struct in C# can not be inherited by another Struct and it can not inherit from another Struct. Also, a Struct in C# can not have a virtual method. Because it is a Value Type, but a Struct can inherit from an interface in C#.