Samir Bhogayta
Structs are largely redundant in C++.Why does C# have them?
By Samir Bhogayta in C# on Jun 25 2016
  • Samir Bhogayta
    Jun, 2016 25

    In C++, a struct and a class are pretty much the same thing. The only difference is the default visibility level (public for structs, private for classes). However, in C# structs and classes are very different. In C#, structs are value types (instances stored directly on the stack, or inline within heap-based objects), whereas classes are reference types (instances stored on the heap, accessed indirectly via a reference). Also structs cannot inherit from structs or classes, though they can implement interfaces. Structs cannot have destructors. A C# struct is much more like a C struct than a C++ struct.

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS