Q:

How will you differentiate between a Class and a Struct in c#?

0

How will you differentiate between a Class and a Struct?

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

In .NET, there are two categories of types, reference types and value types. Although both class and structure are user-defined data types, they are different in several fundamental ways. A class is a reference type and Struct is a value type.

The general difference is that a reference type lives on the heap, and a value type lives inline, that is, wherever it is your variable or field is defined.

While the structure doesn’t support inheritance and polymorphism, the class provides support for both. A class can be of an abstract type, but a structure can’t.

All members of a class are private by default, while members of a struct are public by default. Another distinction between class and struct is based on memory management. The former supports garbage collection while the latter doesn’t.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C# Interview Questions and Answers,You Need To Know

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
What is the difference between public, static, and... >>
<< What is the meaning of instantiation in c#?...