C# Interview Questions and Answers
<< Previous Question Next Question >>
 Question: 1851 Page Views: 

What is the difference between a Struct and a Class?



Posted By: Avi Date: 13 October 2009 11:20:40 PM
 Answer:

Following are the two major differences between a Struct and a Class:

1) Struct is a value type while Class is a reference type. So the class is saved on stack and class is saved on heap.

2) Struct cannot inherit while Class can inherit another Class.


Posted By: eTechPlanet


Date: 13 October 2009 11:20:40 PM
Post a better Answer if you have
 
(Will show your Gravatar icon)  
  Country flag

Loading
Enter the text as shown in the image XCwLzs
Related Questions
C# : What is the scope of a class member declared as protected?

What is the scope of a class member declared as protected?

Class member declared as protected can be accessed either only within the same class or within the c....
Category: C# Date: 10/30/2009 7:03:34 AM
C# : How do you mark a method obsolete in C#?

How do you mark a method obsolete in C#?

[Obsolete] public int MethodName() {...} OR [Obsolete(\"This is a message describing why this....
Category: C# Date: 10/30/2009 6:54:21 AM
C# : Is it possible to override private virtual methods?

Is it possible to override private virtual methods?

It's not possible to declare a method as 'private virtual'. So overriding private virtual method doe....
Category: C# Date: 10/28/2009 5:36:41 AM
C# : What is the use of "fixed" statement in C#?

What is the use of "fixed" statement in C#?

The "fixed" statement prevents the garbage collector from relocating a movable variable. T....
Category: C# Date: 10/28/2009 5:25:18 AM
C# : Will finally block get executed if the exception had not occurred?