Chapter 18
Answers to Chapter 18 Review Questions
1: | List three kinds of data abstractions where structs should be considered instead of classes. |
A1: |
|
2: | Mention the important similarities and differences between classes and structs. |
A2: | Similarities: structs and classes can both contain methods, properties, indexers, constructors, data members, operator methods, nested types; both can implement interfaces; and they both implicitly inherit from the System.Object class.
Differences: Structs cannot contain destructors; their constructors work in a slightly different way. Structs form value types, whereas classes ... |
Get C# Primer Plus now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.