Lecture overview -- Keyboard shortcut: 'u'  Previous page: Structs and Initialization -- Keyboard shortcut: 'p'  Next page: Examples of mutable structs in C# -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home  Page 12 : 29
Object-oriented Programming in C#
Reference types, Value types, and Patterns
Structs versus classes

Here we present a back-to-back comparison of classes and structs.

Structs and classes are similar in C#

Classes

Structs

Reference type

Value type

Used with dynamic instantiation

Used with static instantiation

Ancestors of class Object

Ancestors of class Object

Can be extended by inheritance

Cannot be extended by inheritance

Can implement one or more interfaces

Can implement one or more interfaces

Can initialize fields with initializers

Cannot initialize fields with initializers

Can have a parameterless constructor

Cannot have a parameterless constructor