C# Language

Core C# language constructs covering type system features, functional patterns, and performance-oriented collections.

Pages

  • Delegatesmulticast delegates as the foundation for callbacks and notifications
  • Events — event-based notification patterns built on top of delegates
  • Lambdas — lambda expressions, Expression<T>, and delegate/expression tree duality
  • Anonymous Types — compiler-generated immutable projection types for on-the-fly composition
  • Co/Contra Variance — generic type compatibility rules: covariance and contravariance
  • Collections Performance — performance comparison of Dictionary, List, HashSet, and other collection types
  • Exceptions — stack trace preservation, throw vs throw ex, and exception handling patterns
  • Immutable Types — immutability patterns, Lookup<K,V>, and value-type design guidelines
  • InterfacesIComparable, IEnumerable, and interface contract patterns
  • Managed C++/CLI — C++/CLI syntax as the successor to Managed C++ for .NET interop
  • RxReactive Extensions (Rx.NET): observables, events, and tuple deconstruction

Notnull Constraint

The non-null constraint uses the contextual keyword notnull. Triggers a warning if a nullable type is specified for the decorated type parameter.

public class EntityDictionary<TKey, TValue> :
    System.Collections.Generic.Dictionary<TKey, TValue>
    where TKey : notnull
    where TValue : EntityBase
< «

Table of contents