what are the differences b/w structure and class?

Answers were Sorted based on User's Feedback



what are the differences b/w structure and class? ..

Answer / purushotham .tella

Structures are Value-Types. This means, the data that they
contain is stored as a stack on the memory. Classes are
Reference-Types, means they are stored as a heap on the memory.

Structures are implicitly derived from a class called
System.ValueType.

Is This Answer Correct ?    14 Yes 0 No

what are the differences b/w structure and class? ..

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

what are the differences b/w structure and class? ..

Answer / dhinakaran

Class is a reference Type.
structure is a value Type.

Is This Answer Correct ?    4 Yes 0 No

what are the differences b/w structure and class? ..

Answer / jones

***class can have constructor, but structure cant have
constructor.***

***class can have garbage collector, but structure cant
have garbage collector***

Is This Answer Correct ?    5 Yes 2 No

what are the differences b/w structure and class? ..

Answer / sai laxman

class ex:-
class classname
{
int a;
float b;
}
struct {
int a;
int b;
}struct name;

In the struct all members are by default public,
in the class we can deference it private,public,protected.
While Inheriting from the structure all the members are
public by default but in class it depends upon the data
access modifiers.

Is This Answer Correct ?    7 Yes 6 No

what are the differences b/w structure and class? ..

Answer / abhay k pandey

Structs many have constructors but they should not be
parameterless. Structs performs alomost all the tasks of a
class but differs at some points - structs don't support
inheritance hence there is no protected keyword with
structs. Note : still struct inherit from System.Object

Is This Answer Correct ?    1 Yes 0 No

what are the differences b/w structure and class? ..

Answer / ctharam

Struct:-
-------
1) by default, Public
2) doesn't support OOP's Concepts.
3) doesn't support Constructor and Destructor member functions.
4) No Security for data.

Class:-
-------
1) by default ,Private
2) its support OOP's Concepts.
3) supports Constructor and Destructor .
4) provides highly security for user's data.

Is This Answer Correct ?    1 Yes 0 No

what are the differences b/w structure and class? ..

Answer / sagu

In classes we can code functions which is not possible in
structures. In structures the number of members is
restricted to ten.whereas in c language we can use as many
members we required.

Is This Answer Correct ?    1 Yes 1 No

what are the differences b/w structure and class? ..

Answer / srikanth chodavarapu

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. class can have constructor, but structure cant have
constructor.
3. class can have garbage collector, but structure cant
have garbage collector.

Is This Answer Correct ?    1 Yes 2 No

what are the differences b/w structure and class? ..

Answer / rajesh

the only main difference b/w structure and class is by
default all members of structure are "public" where as for
the class they are "private",other wise structure is same
as class.All these answers have no sense

Is This Answer Correct ?    3 Yes 8 No

Post New Answer

More C Sharp Interview Questions

What is serialization and deserialization in c# with example?

0 Answers  


How do you implement multiple inheritance in .NET?

10 Answers   Microsoft,


Explain the difference between private and shared assembly?

0 Answers  


What is the use of GC.KeepAlive Method?

0 Answers   HCL,


What is ac callback?

0 Answers  






What is inner class in c#?

0 Answers  


How do you read an Excel sheet in C#?

0 Answers   MindCracker,


What are async and await?

0 Answers  


How to use nullable types in .net?

0 Answers  


What does return do in unity?

0 Answers  


Explain anonymous type in c#?

0 Answers  


What are the differences between events and delegates in c#?

0 Answers  


Categories