Class v. Structure

J

Just Me

Is there any performance considerations for a web service returning a
structure versus an instance of a class?
 
M

Michael Nemtsev

Hello Just,

JM> Is there any performance considerations for a web service returning
JM> a structure versus an instance of a class?

Seems not, coz both of them need to be serialized
 
J

Just Me

Methods do not get serialized so it would seem more straighforward,
clearer, more inutitive, etc. in reading the code to use structures.
I know in .Net, structures can have methods, but I've used them in the
past strictly for grouping relate elements/data types.

The differentiation I'm thinking of that may be pertinent to performance
is that structures are created on the stack versus on the heap for class
instances. My guess is that for small sets of data, perhaps the
structure is better and the opposite is true for returning large sets of
data. I really do not know.

I have not found any discussion of such in MSDN or otherwise. I'm
curious to know if anyone has any remotely conclusive evidence or
experience. Thanks.
 
M

Michael Nemtsev

Hello Just,

JM> The differentiation I'm thinking of that may be pertinent to
JM> performance is that structures are created on the stack versus on
JM> the heap for class instances. My guess is that for small sets of
JM> data, perhaps the structure is better and the opposite is true for
JM> returning large sets of data. I really do not know.

Yep, everything is all right as u described.

it depends on how u treats that data afterwards u get them? If it's in vast
using - use class,
if it's only returning data with short period of life - use stucture.

Web-service doesnt' have sense in this way
 
J

Just Me

Thank you for your replies and confirming my thoughts. Best regards.

Michael Nemtsev wrote:
 

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

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,830
Latest member
HeleneMull

Latest Threads

Top