Why use a Struct instead of a Class

P

Paul Aspinall

Hi
I've used both Struct and Classes. However, after reading a few articles
lately, I'm starting to wonder why you would really use a Struct over a
class.

The only reason seems to be that Structs are Valuetypes, and can perform
better with smaller data types (ie < 16 bytes). But in the kind of apps I
write, this is very rarely a consideration, and therefore I prefer to use
classes all the time.

Am I alone in this??

Thanks


Paul
 
R

randolpho

No, most of the time, you should use a class. Structs are for very
specialized needs when you *want* value-type semantics. For the most
part, reference-type semantics are better.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top