Objects

This part of the C# course builds objects. A class starts from its fields and a constructor, then takes properties, primary constructors and static members; structs, records and record structs follow as the value shapes beside it. Inheritance, abstract classes, virtual and sealed come next, then interfaces with their default members, generics with constraints, variance, extension methods, operators, indexers and iterators.

4.1 Classes fields, methods, new, this, access modifiers Open 4.2 Constructors and static members a constructor, an object initialiser, const and static readonly Open 4.3 Properties and primary constructors auto-properties, init, required, a computed property, a primary constructor Open 4.4 Structs value semantics, readonly struct, ref struct and its limits Open 4.5 Records positional syntax, value equality, with, ToString Open 4.6 Record structs record struct, readonly record struct, when a value record is right Open 4.7 Inheritance : Base, base, constructor chaining, what is inherited Open 4.8 Abstract classes abstract, an abstract member, a template method Open 4.9 virtual, override and polymorphism new against override, dispatch, the call a reader expects Open 4.10 sealed and sealed hierarchies sealed, sealed override, a private constructor, a closed set of types Open 4.11 Interfaces an implementation, several interfaces, an interface against an abstract class Open 4.12 Default interface members a default implementation, a static abstract member Open 4.13 Generics and constraints a generic type and method, where, default(T) Open 4.14 Variance out and in, covariance and contravariance, invariance and the error Open 4.15 Extension methods this, resolution, a chain Open 4.16 Operators and indexers operator overloading, implicit and explicit, an indexer, IEquatable Open 4.17 Iterators and yield yield return, IEnumerable, a lazy sequence, yield break Open

Lessons