Question about structs

  • Thread starter Thread starter Neil
  • Start date Start date
N

Neil

Hi ,

Quick quetion to help me understand vb.net a bit more.

Why would you use structs as I cant see advantage of using them as I would
always use class. I think that struct go on the stack which isnt as big as
the heep which is used by class objects.

Is this correct,also any examples of uses/differences ?

Thanks
 
* "Neil said:
Quick quetion to help me understand vb.net a bit more.

Why would you use structs as I cant see advantage of using them as I would
always use class. I think that struct go on the stack which isnt as big as
the heep which is used by class objects.

Have a look at the .NET Framework and you will see when it makes sense
to use a structure and when to use a class. Structures are stored on
the stack, they are value types. This makes copying the structure
easier. Structs should always be < 16 bytes, I read somewhere.

;->
 
Back
Top