Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Class and Structure

Status
Not open for further replies.

RicoCali

Programmer
Dec 7, 2002
80
0
0
US
I have been experimenting with Class and Structure and really don't see any difference. Can someone explain to me the difference?
 
since .net there isnt much difference I think it still there for backward compatability

msdn said:
Structures support many of the same features as classes. For example, structures can have properties and methods, they can implement interfaces, and they can have parameterized constructors. However, there are significant differences between structures and classes in areas such as inheritance, declarations, and usage.


Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
There is a BIG difference. When an object, which is a Reference Type, is passed ByVal, the reference for the object is passed and thus changes made through the ByVal argument still affect the original object. When a structure, which is a Value Type, is passed ByVal, changes made to the values in the structure do not affect the original structure values. However, changes made to objects referenced in the structure DO affect the original object except that if you change the reference in the passed structure, the original structure will not be affected. You will notice that Framework uses structures such as Color, Point, Rectangle etc. usually ONLY as read-only. The values in the structure can usually only be set by the NEW constructor.

Forms/Controls Resizing/Tabbing
Compare Code
Generate Sort Class in VB
Check To MS)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top