66 Contributors: 6 Wednesday, September 14, 2016
Licensed under: CC-BY-SA
Not affiliated with Stack Overflow
Rip Tutorial:
Roadmap: roadmap
Download eBook


Download c# eBook


Unlike classes, a struct is a value type, and is created on the local stack and not on the managed heap, by default. This means that once the specific stack goes out of scope, the struct is de-allocated. Contained reference types of de-allocated structs are also swept, once the GC determines they are not longer referenced to by the struct.

structs cannot inherit and cannot be bases for inheritance, they are implicitly sealed, and also cannot include protected members. However, a struct can implement an interface, as classes do.

Related Examples