Anonymous Types
- Private nested type with read-only properties is created.
- Var keyword is needed to reference an anonymous type, because the type’s name is compiler-generated.
Basic
- General purpose.
- Object oriented.
- Type safe.
- Case sensitive.
Attributes
- Attributes are an extensible mechanism for adding custom information to code elements.
- Named attribute are parameters for attribute type’s constructor.
- Positional attributes are public fields or properties.
[AttributeUsage (AttributeTargets.Method)]
Miscellaneous
- foreach statement is a consumer of an enumerator, an iterator is a producer of an enumerator.
- yield and yield break.
int? i = null; //? Allows null
- Extension methods allow an existing type to be extended with new methods.
- Instance method has precedence over extension method.
Lamda Expression
- (parameters) => expression-or-statement-block.
- Local variables and parameters referenced by a lambda expression are called outer variables or captured variables.
- A lambda expression that includes outer variables is called a closure.
Event
- Event formalizes the broadcaster, subscriber pattern.
- Code within the broadcaster type has full access to delegate.
Code outside of broadcaster can only perform += and -= operations. No delegate invocation.