Since Structures seem to have many of the features of a Class (methods/events etc), under what circumstances should I be using a Structure instead of a Class, or indeed vice versa?
It's a value type (memory comes from the stack), whereas a class is a reference type (the pointer to the class comes from the stack, but memory for the guts of the class come from the heap).
While you can add methods and such to a structure, I myself don't see that as a good use. I prefer to think of a structure as a simple place to hold a small amount of data. If I need to manage a large amount of data (like, for a customer), or need nested data (Invoice + it's detail lines), then I'd use a class.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.