why sturcture ? why class?why you prefer structure and in
which cases u go for class?

Answer Posted / supraja

Class
-->It is reference type
-->The values allocated in heap
-->Can have constructors, properties, methods
-->Abstract and sealed are possible
-->We cannot have parameter less constructor
-->We can overload constructors
-->Reference type
-->Supports data members, code members (methods) and events
-->Supports inheritance
-->Preferable when you need to initialize one or more
members upon creation
-->Can have parameterized constructors
-->More flexible, unlimited event handling support

Structure
-->It is value type
-->The values allocated in stack
-->Can have constructors, properties, methods
-->Abstract and sealed are not possible
-->By default public
-->We cannot have parameter less constructor
-->We can overload constructors
-->Value type
-->Supports data members, code members (methods) and events
-->Can not inherit
-->Preferable when you perform large number of operations
on each instance
-->Can not control initialization using structure variable
-->Less flexible, limited event handling support

Is This Answer Correct ?    4 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain dataset.acceptchanges method in .net?

614


Can an exception be thrown from a catch block?

649


Why do I get a security exception when I try to run my c# app?

635


Why linq is having select clause at the end?

604


What is the difference between firstordefault and first?

547






How many parameters can a method have c#?

561


What is an example of delegation?

580


What is the symbol used for in c#?

592


Does hashset allow duplicates c#?

605


Is int a class in c#?

626


What is a interface in c#?

548


What is difference between struct and class in c#?

551


Does a loop recorder have to be removed?

690


Explain how to parse a datetime string?

577


What is meant by collections in c#?

530