When do you generally use a class over a struct?
Answer / Ankit Srivastava
Use a class when:
1. You need to create an object with state that can change during the lifetime of the object.
2. The object needs to be subclassed or inherit from other classes.
3. The object requires methods in addition to properties.nUse a struct when:
1. The value is small and frequently used as a parameter for methods without needing to change its state.
2. It's more efficient memory-wise than using a class (due to stack allocation instead of heap allocation).
| Is This Answer Correct ? | 0 Yes | 0 No |
Distinguish between a class and struct?
How do you serialize an object?
Why would you use a class property in c#?
What is visual c# net?
What does readonly mean in c#?
What is the difference between interface and functional interface?
What is difference between write and writeline?
Explain the difference between boxing and unboxing.
Describe the process of “exception handling implementation” in c#?
Explain how many types of exception handlers are there in .net?
Are there constructors in c sharp?
What is the wildcard character in SQL? Let?s say you want to query database with LIKE for all employees whose name starts with La.
Visual Basic (800)
C Sharp (3816)
ASP.NET (3180)
VB.NET (461)
COM+ (79)
ADO.NET (717)
IIS (369)
MTS (11)
Crystal Reports (81)
BizTalk (89)
Dot Net (2435)
Exchange Server (362)
SharePoint (720)
WCF (340)
MS Office Microsoft (6963)
LINQ Language-Integrated Query (317)
WPF (371)
TypeScript (144)
Microsoft Related AllOther (311)