Click to See Complete Forum and Search --> : Structures in VB.net


ambreesh
September 8th, 2005, 02:35 AM
do we suports Structures in vb.net, similar to C -

Struct
{
}

let me know if someone knows an answer to this.

Boumxyz2
September 8th, 2005, 02:39 AM
yes vb does take a look

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vastmStructure.asp

ambreesh
September 8th, 2005, 02:13 PM
This structure thing in VB.net actually supports methods and stuff, means that i behaves exactly like a class with the only difference that the struct cannot inherit information.

then under what cases would i decide on the difference between a structure and a class?

jhammer
September 8th, 2005, 04:04 PM
Structure is a value type.
class is a reference type.

That means that structure is more effective - when boxing isn't needed.
Boxing is what happens when you need to treat a value type as reference type.

There is plenty of material on that subject on the net.

jmcilhinney
September 8th, 2005, 06:37 PM
Structures are generally good for simple, relatively small data types, particularly with value-type fields, that do not need to be inherited and do not require a constructor with no arguments.