what are the differences b/w structure and class?

Answer Posted / kiran

Following are the key differences between them :-
1. Structure are value types and classes are reference
types.So structures use
stack and classes use heap.
2. Structures members can not be declared as protected ,
but class members can
be.You can not do inheritance in structures.
3. Structures do not require constructors while classes
require.
4. Objects created from classes are terminated using
Garbage collector.Structures are not destroyed using GC.

Is This Answer Correct ?    14 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is .dbml file?

483


What is the difference between and xml documentation tag?

528


How to use the sreamReader class to read form a text file?

554


What are delegates in C#?

567


What is default value of enum c#?

464






What is dynamic dispatch?

552


What is the difference between int and int in c#?

496


What is the difference between ref & out parameters in c#?

463


What are delegates and why are they required?

512


Is string primitive?

499


What are controls in c#?

480


What is an example of delegation?

503


What is the difference between dynamic and var in c#?

467


Explain the process of polymorphism with an example?

479


What are the steps to create a webservice and consume it?

475