C# Interview Questions with Answers Pdf - 5

Question: 21

What is the difference between struct and class in C#?

Structs cannot be inherited.

Structs are passed by value, not by reference.

Struct is stored on the stack, not the heap.

Question: 22

Can you create enumerated data types in C#?

Yes

Question: 23

Is gotostatement supported in C#?

Gotos are supported in C# to the fullest. In Java goto is a reserved keyword that provides absolutely no functionality.

Question: 24

What is the difference between the value-type variables and reference- type variables in terms of garbage collection?

The value-type variables are not garbage-collected, they just fall off the stack when they fall out of scope, the reference-type objects are picked up by GC when their references go null.

Related Questions