31. What is a delegate?
A type that references a method with a specific signature.
32. What is an event?
A mechanism that allows a class to notify subscribers when something happens.
33. Difference between delegate and event?
- Delegate: points to methods
- Event: restricts delegate access to only the declaring class
34. What is Func, Action, and Predicate?
- Func: returns a value
- Action: returns void
- Predicate: returns bool
35. What are generics?
Allow type-safe data structures and methods without specifying a concrete type.
36. What is covariance and contravariance?
- Covariance: allows derived type assignment to base type in return values
- Contravariance: allows base type assignment to derived type in parameters
37. What is reflection?
Inspect metadata, types, and methods at runtime.
38. What is boxing and unboxing?
Already answered in basics — converting value types to object and back.
39. What are attributes in C#?
Metadata applied to classes, methods, properties, which can be read at runtime.
40. What is nullable type?
Allows value types to be null using ?, e.g., int? x = null.
41. What is the difference between == and Equals()?
Already covered — value vs reference equality.
42. What is a sealed class?
Cannot be inherited.
43. What is a static constructor?
Runs once when the class is first accessed; initializes static members.
44. What is operator overloading?
Customizing operators (+, -, etc.) for user-defined types.
45. What is this keyword?
Refers to the current instance of the class.