Struct of Class

S

Simon Hart

Hi,

Is there any benefit in terms of performance to using a Struct over a class
to store objects?

Regards
Simon.
 
J

Jon Skeet [C# MVP]

J. Verdrengh said:
From
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csre
f/html/vcrefstructtypes.asp:

Unless you need reference type semantics, a class that is smaller than 16
bytes may be more efficiently handled by the system as a struct.

In my experience, however, the desired semantics are a *much* bigger
issue than the efficiency. I rarely come across a case where I don't
mind what kind of semantics I use.
 

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