Class
14 pages.
A class is an in-memory shape — data plus the behaviour that belongs to it — and it never touches the database. That is the whole distinction from an…
A class can derive from another class with `class Circle : Shape`, inheriting its fields and its methods to any depth. A value of the derived type…
`==` on two class values compares them BY VALUE, field by field, rather than by reference. A class is a value you build rather than a row you hold…
`with` makes a COPY of a class value and replaces the fields you name. Everything you do not name comes from the value you copied, and the original…
A class can declare type parameters, so one shape serves every type it is used with instead of being copied per entity. The type argument is written…
A class can declare several methods with the same name, as long as they differ in their parameter types. Each call picks the one that fits its…
A class can hold many values in one field — `string[]`, `int[]`, `List<Tag>`, `HashSet<string>`, `Dictionary<string, int>`. The element may be a…
`s is Circle` asks which type a value actually is at run time, answering by the value's own type rather than the type it is declared as. A derived…
`params` lets a method be called with any number of trailing arguments — `Total(1m, 2m, 3m)` — which arrive as one array. It must be the last…
A `readonly` field can be assigned only where it is declared or in a constructor of the class that declares it. Everywhere else — a method of the…
A `static` method belongs to the type rather than to any instance, and is called on the type name — `Money.Round(x)`. It has no `this`, so it cannot…
Behaviour attached to a class — a method with a receiver, called as value.Method(). Classes are in-memory values, so a method is the natural place…
A class member that reads and writes like a field but runs a body on access — a computed value, a validating setter, or an auto-property whose…
A class declares one constructor — its name is the class name, it takes no return type, and it runs when you write new T(args). The constructor body…