C# 参考C# reference

此部分收录了有关 C# 关键字、运算符、特殊字符、预处理器指令、编译器选项以及编译器错误与警告的参考资料。This section provides reference material about C# keywords, operators, special characters, preprocessor directives, compiler options, and compiler errors and warnings.

本节内容In this section

C# 关键字C# Keywords
提供指向有关 C# 关键字和语法的信息的链接。Provides links to information about C# keywords and syntax.

C# 运算符C# Operators
提供指向有关 C# 运算符和语法的信息的链接。Provides links to information about C# operators and syntax.

C# 特殊字符C# Special Characters
收录了主题链接,有助于你了解 C# 中的特殊上下文字符及其用法。Provides links to information about special contextual characters in C# and their usage.

C# 预处理器指令C# Preprocessor Directives
提供用于嵌入 C# 源代码中的编译器命令有关的信息的链接。Provides links to information about compiler commands for embedding in C# source code.

C# 编译器选项C# Compiler Options
包括有关编译器选项以及如何使用这些选项的信息。Includes information about compiler options and how to use them.

C# 编译器错误C# Compiler Errors
包括演示原因和更正 C# 编译器错误和警告的代码片段。Includes code snippets that demonstrate the cause and correction of C# compiler errors and warnings.

C# 语言规范C# Language Specification
C# 6.0 语言规范。The C# 6.0 language specification. 本文是针对 C# 6.0 语言的建议草案。This is a draft proposal for the C# 6.0 language. 本文档将通过与 ECMA C# 标准委员会协作来进行优化。This document will be refined through work with the ECMA C# standards committee. 版本 5.0 已于 2017 年 12 月发布为 Standard ECMA-334 第 5 版文档。Version 5.0 has been released in December 2017 as the Standard ECMA-334 5th Edition document.

已在 C# 6.0 之后的版本中实现的功能将表示在语言规范建议中。The features that have been implemented in C# versions after 6.0 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. 这些规范将经过优化并提交到 ECMA 标准委员会,以便正式审查并合并到 C# 标准的未来版本。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 规范建议C# 7.0 Specification Proposals
C# 7.0 中实现了许多新功能。There are a number of new features implemented in C# 7.0. 这些功能包括:模式匹配、本地函数、out 变量声明、throw 表达式、二进制文本和数字分隔符。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 规范建议C# 7.1 Specification Proposals
C# 7.1 中有以下新增功能。There are new features added in C# 7.1. 首先,可编写返回 TaskTask<int>Main 方法。First, you can write a Main method that returns Task or Task<int>. 由此可将 async 修饰符添加到 MainThis enables you to add the async modifier to Main. 可推断类型的位置中没有类型时可使用 default 表达式。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 规范建议C# 7.2 Specification Proposals
C#7.2 添加了大量小功能。C# 7.2 added a number of small features. 可使用 in 关键字通过只读引用传递参数。You can pass arguments by readonly reference using the in keyword. 许多低级更改可支持 Span 及相关类型的编译时安全性。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. 借助 private protected 访问修饰符,可指定调用方仅限于在同一程序集中实现的派生类型。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 规范建议C# 7.3 Specification Proposals
C# 7.3 是另一个包含多个小更新的重要发布。C# 7.3 is another point release that includes several small updates. 可对泛型类型参数使用新约束。You can use new constraints on generic type parameters. 通过其他更改,可更轻松地使用 fixed 字段,包括使用 stackalloc 分配。Other changes make it easier to work with fixed fields, including using stackalloc allocations. 可以重新分配使用 ref 关键字声明的本地变量以引用新存储。Local variables declared with the ref keyword may be reasssigned 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 规范建议C# 8.0 Specification Proposals
C# 8.0 可用于 .NET Core 3.0。C# 8.0 is available with .NET Core 3.0. 这些功能包括可为空引用类型、递归模式匹配、默认接口方法、异步流、范围和索引、基于模式的 using 和 using 声明、null 合并分配以及只读实例成员。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# 指南C# Guide
提供 Visual C# 文档的入口。Provides a portal to Visual C# documentation.

使用 Visual Studio C# 开发环境Using the Visual Studio Development Environment for C#
提供指向介绍 IDE 和编辑器的概念性和任务主题的链接。Provides links to conceptual and task topics that describe the IDE and Editor.

C# 编程指南C# Programming Guide
包括有关如何使用 C# 编程语言的信息。Includes information about how to use the C# programming language.