### Access Modifiers - `public`: Accessible from anywhere. - `private`: Accessible only within the defining class/struct. - `protected`: Accessible within the defining class and by derived classes. - `internal`: Accessible only within the current assembly. - `protected internal`: Accessible within the current assembly OR by derived classes in other assemblies. - `private protected`: Accessible within the defining class AND by derived classes in the same assembly. ### Type Keywords - `class`: Defines a reference type. - `struct`: Defines a value type. - `interface`: Defines a contract that classes or structs can implement. - `enum`: Defines a set of named integral constants. - `delegate`: Defines a reference type that can encapsulate a method. - `record`: Defines an immutable reference type, often used for data transfer. - `void`: Indicates a method does not return a value. - `object`: The ultimate base class for all .NET types. - `string`: Represents a sequence of Unicode characters. - `bool`: Represents a Boolean value (`true` or `false`). - `byte`, `sbyte`: 8-bit integer types. - `short`, `ushort`: 16-bit integer types. - `int`, `uint`: 32-bit integer types. - `long`, `ulong`: 64-bit integer types. - `float`: Single-precision floating-point type. - `double`: Double-precision floating-point type. - `decimal`: High-precision decimal floating-point type. ### Variable Keywords - `var`: Implicitly typed local variable. - `const`: Declares a constant field or local variable. - `readonly`: Declares a field that can only be assigned during declaration or in a constructor. - `static`: Belongs to the type itself, not to a specific instance. - `dynamic`: Bypasses compile-time type checking. - `ref`: Passes arguments by reference. - `out`: Passes arguments by reference for output parameters. - `in`: Passes arguments by reference, but the method cannot modify them. - `this`: Refers to the current instance of the class. - `base`: Accesses members of the base class. - `new`: Creates an object, hides an inherited member. ### Statement Keywords - `if`, `else`: Conditional execution. - `switch`, `case`, `default`: Multi-way branching. - `for`: Loop with initialization, condition, and iteration. - `foreach`, `in`: Iterates over collections. - `while`: Loop that continues as long as a condition is true. - `do`: Loop that executes at least once. - `break`: Exits a loop or `switch` statement. - `continue`: Skips the rest of the current loop iteration. - `return`: Exits a method and optionally returns a value. - `goto`: Transfers control to a labeled statement (generally discouraged). - `checked`, `unchecked`: Controls overflow checking for integral arithmetic operations. - `fixed`: Pins a variable in memory to prevent garbage collection from moving it. - `lock`: Ensures that only one thread can execute a block of code at a time. - `using`: Defines a scope for an object that will be disposed of at the end of the scope. - `yield`: Used in iterator blocks to return a value to the enumerator. ### Exception Handling - `try`: Defines a block of code to monitor for exceptions. - `catch`: Catches exceptions thrown within a `try` block. - `finally`: Executes code regardless of whether an exception occurred. - `throw`: Throws an exception. ### Operator Keywords - `sizeof`: Returns the size in bytes of a value type. - `typeof`: Returns the `System.Type` object for a type. - `is`: Checks if an object is compatible with a given type. - `as`: Performs a type conversion if compatible, otherwise returns `null`. - `new`: Operator for object instantiation. - `await`: Awaits the completion of an asynchronous operation. - `default`: The default value of a type. - `nameof`: Gets the string name of a variable, type, or member. - `stackalloc`: Allocates a block of memory on the stack. ### Modifier Keywords - `abstract`: Indicates that a class or member is incomplete and must be implemented in a derived class. - `virtual`: Allows a method or property to be overridden in a derived class. - `override`: Implements an inherited `virtual` or `abstract` member. - `sealed`: Prevents a class from being inherited or a method from being overridden. - `extern`: Declares a method that is implemented externally (e.g., in unmanaged code). - `unsafe`: Allows code that can manipulate memory directly using pointers. - `async`: Marks a method as asynchronous, enabling the use of `await`. - `partial`: Allows a class, struct, or interface to be defined in multiple source files. - `volatile`: Indicates that a field might be modified by multiple threads simultaneously. ### Query Keywords (LINQ) - `from`: Specifies the data source and range variable. - `where`: Filters elements based on a condition. - `select`: Projects elements into a new form. - `group`, `by`: Groups elements based on a key. - `orderby`, `ascending`, `descending`: Sorts elements. - `join`, `on`, `equals`, `into`: Joins data sources. - `let`: Introduces a new range variable. - `in`: Used with `foreach` and `join` clauses. ### Contextual Keywords (Special Meaning in Context) - `add`: Used in event accessors to add an event handler. - `remove`: Used in event accessors to remove an event handler. - `yield`: Used in an iterator block to specify a value to return. - `value`: Used in property or indexer accessors. - `get`, `set`: Used in property or indexer accessors. - `var`: Implicitly typed local variable. - `async`, `await`: For asynchronous programming. - `global`: Used to access members of the global namespace. - `when`: Used in a `catch` clause to specify a filter condition. - `nint`, `nuint`: Native-sized integer types (since C# 9). - `init`: Used in C# 9 for init-only properties. - `record`: For record types (since C# 9). - `with`: For non-destructive mutation of records (since C# 9). ### Namespace Keywords - `namespace`: Declares a scope that contains a set of related objects. - `using`: Imports namespaces, aliases types, or defines global `using` directives. - `extern alias`: Creates an alias to an assembly. ### Preprocessor Directives - `#define`, `#undef`: Define or undefine preprocessor symbols. - `#if`, `#elif`, `#else`, `#endif`: Conditional compilation. - `#warning`, `#error`: Generate compile-time warnings or errors. - `#line`: Controls line numbers and file names in compiler output. - `#region`, `#endregion`: Mark blocks of code that can be expanded or collapsed. - `#pragma`: Suppresses or restores compiler warnings.