Saturday, October 27, 2007

Class and structure

What are similarities between Class and structure ?

Following are the similarities between classes and structures :-v Both can have constructors, methods, properties, fields, constants,enumerations, events, and event handlers.v Structures and classes can implement interface.v Both of them can have constructors with and without parameter.v Both can have delegates and events.(A) What is the difference between Class and structure’s ?Following are the key differences between them :-v Structure are value types and classes are reference types. So structures usestack and classes use heap.v Structures members can not be declared as protected, but class members canbe. You can not do inheritance in structures.v Structures do not require constructors while classes require.v Objects created from classes are terminated using Garbage collector. Structuresare not destroyed using GC.

No comments: