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 月發行為標準 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 變數宣告、擲回例外狀況、二進位常值,以及數字分隔符號。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. Tuple 成員名稱也可推斷。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. Tuple 可用於比較是否相等 (或不相等)。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. 這些功能包括可為 null 的參考型別、遞迴模式比對、預設介面成員、非同步資料流程、範圍和索引、使用和 using 宣告的模式、null 聯合指派,以及 readonly 實例成員。The features include nullable reference types, recursive pattern matching, default interface members, 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.

使用 C# 的 Visual Studio 開發環境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.