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



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

Answer / 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

More C Sharp Interview Questions

What is the difference between overriding and overloading in systemverilog?

0 Answers  


What does out mean c#?

0 Answers  


Can we override static class in c#?

0 Answers  


FOR EXAMPLE : CLASS Dotnet { } creating object: Dotnet dn=new Dotnet(); NOW THE QUESTION IS WHICH IS CALLED AS OBJECT ?EITHER dn OR new Dotnet() and CAN YOU PROVE YOUR ANSWER?????PLEASE REPLY...

1 Answers  


What does using do in c#?

0 Answers  






What is difference between encapsulation and abstraction in c#?

0 Answers  


what is virtual method in c#?

0 Answers  


What does == mean in c sharp?

0 Answers  


How to add a readonly property in c#.net

0 Answers  


What is foreach loop in c#?

0 Answers  


What is a delegate in c#?

0 Answers  


What is verbatim string literal in c#?

0 Answers  


Categories