C# reference

This section provides reference material about C# keywords, operators, special characters, preprocessor directives, compiler options, and compiler errors and warnings.

In this section

C# Keywords
Provides links to information about C# keywords and syntax.

C# Operators
Provides links to information about C# operators and syntax.

C# Special Characters
Provides links to information about special contextual characters in C# and their usage.

C# Preprocessor Directives
Provides links to information about compiler commands for embedding in C# source code.

C# Compiler Options
Includes information about compiler options and how to use them.

C# Compiler Errors
Includes code snippets that demonstrate the cause and correction of C# compiler errors and warnings.

C# Language Specification
The C# 7.0 draft language specification. This is a draft proposal for the C# 7.0 language. This document will be refined through work with the ECMA C# standards committee. Version 6.0 has been released in June 2022 as the Standard ECMA-334 6th Edition document.

The features that have been implemented in C# versions after 6.0, including those not yet incorporated into the 7.0 draft standard, are represented in language specification proposals. These documents describe the deltas to the language spec in order to add these new features. These are in draft proposal form. These specifications will be refined and submitted to the ECMA standards committee for formal review and incorporation into a future version of the C# Standard.

C# 7.0 Specification Proposals
There are a number of new features implemented in C# 7.0. They include pattern matching, local functions, out variable declarations, throw expressions, binary literals, and digit separators. This folder contains the specifications for each of those features.

C# 7.1 Specification Proposals
There are new features added in C# 7.1. The default expression can be used without a type in locations where the type can be inferred. Also, tuple member names can be inferred. Finally, pattern matching can be used with generics.

C# 7.2 Specification Proposals
C# 7.2 added a number of small features. You can pass arguments by readonly reference using the in keyword. There are a number of low-level changes to support compile-time safety for Span and related types. You can use named arguments where later arguments are positional, in some situations. The private protected access modifier enables you to specify that callers are limited to derived types implemented in the same assembly. The ?: operator can resolve to a reference to a variable. You can also format hexadecimal and binary numbers using a leading digit separator.

C# 7.3 Specification Proposals
C# 7.3 is another point release that includes several small updates. You can use new constraints on generic type parameters. Other changes make it easier to work with fixed fields, including using stackalloc allocations. Local variables declared with the ref keyword may be reassigned to refer to new storage. You can place attributes on auto-implemented properties that target the compiler-generated backing field. Expression variables can be used in initializers. Tuples can be compared for equality (or inequality). There have also been some improvements to overload resolution.

C# 8.0 Specification Proposals
C# 8.0 is available with .NET Core 3.0. The features include nullable reference types, recursive pattern matching, default interface methods, async streams, ranges and indexes, pattern based using and using declarations, null coalescing assignment, and readonly instance members.

C# 9 Specification Proposals
C# 9 is available with .NET 5. The features include records, top-level statements, pattern matching enhancements, init only setters, target-typed new expressions, module initializers, extending partial methods, static anonymous functions, target-typed conditional expressions, covariant return types, extension GetEnumerator in foreach loops, lambda discard parameters, attributes on local functions, native sized integers, function pointers, suppress emitting localsinit flag, and unconstrained type parameter annotations.

C# 10 Specification Proposals
C# 10 is available with .NET 6. The features include record structs, parameterless struct constructors, global using directives, file-scoped namespaces, extended property patterns, improved interpolated strings, constant interpolated strings, lambda improvements, caller-argument expression, enhanced #line directives, generic attributes, improved definite assignment analysis, and AsyncMethodBuilder override.

C# 11 Specification Proposals
C# 11 is available with .NET 7. The new features include static abstract members in interfaces, checked user-defined operators, unsigned right shift operator, relaxing shift operator, numeric IntPtr, raw string literals, interpolated string newline, UTF-8 string literals, pattern match span, list patterns, required members, auto-default struct, low-level struct improvements, extended nameof scope, and file local types.

Using the Visual Studio Development Environment for C#
Provides links to conceptual and task topics that describe the IDE and editor.

C# Programming Guide
Includes information about how to use the C# programming language.