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
Why do we need private constructor in c#?
What are the Types of compatabilities and explain them
What are the fundamental differences between value types and reference types?
In a C# class we have a SortedList member m_addinProjects
we want to provide an iterator to allow the consumer of
this class access to the items in the collection. Please
provide an iterator method for the AnalyzeAddinsDLL class
below and an example of how it would be used.
namespace AnalyzeAddinsDLL
{
public class AllAddInProjects
{
private SortedList
Why do we need constructor in c#?
Why do we use abstraction in c#?
Can we inherit partial class in c#?
Explain how to use an extender provider in the project.
What is the real use of interface in c#?
Explain data types in c#?
List the different stages of a thread?
What is Reflection in .NET? Namespace? How will you load an assembly which is not referenced by current assembly?
How do switch statements work?
Why ref is used in c#?
Can constructor have return type c#?