Why can’t struct be used instead of class for storing entity?



Why can’t struct be used instead of class for storing entity?..

Answer / Jeetender Pal Singh

In C#, structures (structs) are value types while classes are reference types. This difference leads to some limitations when using structs as entities. For instance, they cannot inherit from multiple base classes or implement interfaces, they don't support constructors with parameters, and they don’t have a built-in concept of inheritance. Structs also can’t be used to create a true object-oriented programming (OOP) model like classes.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Sharp Interview Questions

What is static class in C#?

1 Answers   Winsol Solutions,


How to authenticate web service? When you enter the web service url in browser it should ask username and password. After entering the un&pwd we have to show its methods and service description(wsdl).

3 Answers  


Whats an assembly? Describe the importance of assembly?

1 Answers   Siebel,


What is datacontract in c#?

1 Answers  


What is serialization in unity?

1 Answers  


Oops concepts ?

2 Answers   Accenture, Digital GlobalSoft,


What?s the top .NET class that everything is derived from?

7 Answers  


What is readline library?

1 Answers  


Why are c# strings immutable?

1 Answers  


What is a static class in c#?

1 Answers  


Can a structure be inherited by a class?

3 Answers  


What is the purpose of private constructor in c#?

1 Answers  


Categories