C# classes, properties, records, structs, inheritance, interfaces, generics, delegates and events.
40 cards · basic cards · AI-written, checked twice. Edit anything.
- What keyword defines a reference type that groups data and methods together?
Show answer
class
- What is an abstract class?
Show answer
A class that cannot be instantiated and is designed to be inherited from
- What keyword prevents a class from being inherited?
Show answer
sealed
- What is an abstract method?
Show answer
A method with no implementation that derived classes must override
- Can a class inherit from a struct in C#?
Show answer
No, a class cannot inherit from a value type
- What is an auto-property in C#?
Show answer
A property where the compiler automatically creates a hidden backing field
- What syntax defines an auto-property with both get and set?
Show answer
`public string Name { get; set; }`
- What is an init accessor on a property?
Show answer
A property accessor that allows assignment only during object initialization
- How do you create a read-only property in C#?
Show answer
Define a property with only a get accessor and no set accessor
- What is a backing field?
Show answer
The private field that stores the actual value for a property
- What is a record in C#?
Show answer
A reference type designed for holding data with built-in support for immutability and value-based equality
- What keyword creates an immutable record property?
Show answer
init
- What is the primary difference between a record and a class?
Show answer
Records have value-based equality by default; classes have reference-based equality
- What keyword declares a value type allocated on the stack?
Show answer
struct
- Where are structs typically allocated in memory?
Show answer
On the stack (for local variables) or inline within other types