清香米兰 發表於 2025-4-24 10:16:00

C#高性能开发之类型系统:从 C# 7.0 到 C# 14 的类型系统演进全景

<section id="nice" style="background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); width: auto; font-family: Optima, &quot;Microsoft YaHei&quot;, PingFangSC-regular, serif; font-size: 16px; color: rgba(0, 0, 0, 1); line-height: 1.5em; word-spacing: 0; letter-spacing: 0; overflow-wrap: break-word; text-align: left; padding: 0 10px; margin: 0" data-tool="mdnice编辑器" data-website="https://www.mdnice.com">
<p style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; text-indent: 0; padding: 16px 0 8px; margin: 0" data-tool="mdnice编辑器">自C# 7.0以来,C#语言在类型系统方面引入了众多新数据类型、类型构造和语言特性,以提升性能、类型安全性和开发效率。本文全面整理了从C# 7.0到C# 14.0(截至2025年4月,C# 14.0为预览版)类型系统的新增内容,包括值元组、<code style="color: rgba(40, 202, 113, 1); font-size: 14px; line-height: 1.8em; letter-spacing: 0; background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; height: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">Span&lt;T&gt;</code>、<code style="color: rgba(40, 202, 113, 1); font-size: 14px; line-height: 1.8em; letter-spacing: 0; background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; height: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">ReadOnlySpan&lt;T&gt;</code>、<code style="color: rgba(40, 202, 113, 1); font-size: 14px; line-height: 1.8em; letter-spacing: 0; background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; height: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">Memory&lt;T&gt;</code>、<code style="color: rgba(40, 202, 113, 1); font-size: 14px; line-height: 1.8em; letter-spacing: 0; background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; height: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">ReadOnlyMemory&lt;T&gt;</code>、可空引用类型、记录、本机大小整数、记录结构、内联数组,以及其他增强(如只读结构、泛型数学支持)。</p>
<h2 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: flex; flex-direction: unset; float: unset; height: auto; justify-content: center; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 20px; color: rgba(255, 255, 255, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(130, 127, 196, 1); line-height: 1.5em; letter-spacing: 0; align-items: center; border-radius: 30px; box-shadow: none; display: flex; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: center; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 10px; margin: 0; border: 1px none rgba(0, 0, 0, 1)">版本概览</span></h2>
<p style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; text-indent: 0; padding: 16px 0 8px; margin: 0" data-tool="mdnice编辑器">以下是C# 7.0至C# 14.0中类型系统新增或增强的主要内容:</p>
<section class="table-container" style="overflow-x: auto; padding: 0; margin: 0" data-tool="mdnice编辑器">
<table style="display: table; text-align: left">
<thead>
<tr>
<th style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: bold; background: none left top / auto no-repeat scroll padding-box border-box rgba(240, 240, 240, 1); width: auto; height: auto; border-radius: 0; min-width: 85px; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">C# 版本</th>
<th style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: bold; background: none left top / auto no-repeat scroll padding-box border-box rgba(240, 240, 240, 1); width: auto; height: auto; border-radius: 0; min-width: 85px; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">新增/增强内容</th>
<th style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: bold; background: none left top / auto no-repeat scroll padding-box border-box rgba(240, 240, 240, 1); width: auto; height: auto; border-radius: 0; min-width: 85px; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">发布年份</th>
<th style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: bold; background: none left top / auto no-repeat scroll padding-box border-box rgba(240, 240, 240, 1); width: auto; height: auto; border-radius: 0; min-width: 85px; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">描述</th>
</tr>
</thead>
<tbody style="font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: normal; border-image: initial; border: 0">
<tr style="color: rgba(63, 63, 63, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(255, 255, 255, 1); width: auto; height: auto">
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">7.0</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">值元组(Value Tuples)</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">2017</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">轻量级数据结构,支持多值返回和解构</td>
</tr>
<tr style="color: rgba(0, 0, 0, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(248, 248, 248, 1); width: auto; height: auto">
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">7.2</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">Span, ReadOnlySpan, 只读结构, 引用结构</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">2017</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">高性能内存操作和不可变/栈分配结构体</td>
</tr>
<tr style="color: rgba(63, 63, 63, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(255, 255, 255, 1); width: auto; height: auto">
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">8.0</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">可空引用类型, Memory, ReadOnlyMemory</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">2019</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">空值安全性和托管内存块</td>
</tr>
<tr style="color: rgba(0, 0, 0, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(248, 248, 248, 1); width: auto; height: auto">
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">9.0</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">记录, 本机大小整数, 初始化器专用类型</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">2020</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">值语义引用类型、本机整数和不可变属性</td>
</tr>
<tr style="color: rgba(63, 63, 63, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(255, 255, 255, 1); width: auto; height: auto">
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">10.0</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">记录结构, 全局 using 指令</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">2021</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">值类型记录和简化类型引用</td>
</tr>
<tr style="color: rgba(0, 0, 0, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(248, 248, 248, 1); width: auto; height: auto">
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">11.0</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">必需成员, 泛型数学支持, 文件局部类型</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">2022</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">强制初始化、泛型运算和类型作用域限制</td>
</tr>
<tr style="color: rgba(63, 63, 63, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(255, 255, 255, 1); width: auto; height: auto">
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">12.0</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">内联数组</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">2023</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">固定大小数组结构,优化性能</td>
</tr>
<tr style="color: rgba(0, 0, 0, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(248, 248, 248, 1); width: auto; height: auto">
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">13.0</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">参数集合扩展, 引用结构接口支持, 部分属性</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">2024</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">扩展params、ref struct接口和部分属性定义</td>
</tr>
<tr style="color: rgba(63, 63, 63, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(255, 255, 255, 1); width: auto; height: auto">
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">14.0</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px"><code>field</code> 关键字, 隐式 span 转换, <code>nameof</code> 增强, lambda 参数修饰符, partial 成员扩展, 空条件赋值</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">2025</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">增强属性访问、span 使用、泛型处理、lambda 表达、partial 类型和空值处理</td>
</tr>
</tbody>
</table>
</section>
<blockquote class="custom-blockquote multiquote-1" style="border-radius: 0; background: none left top / auto no-repeat scroll padding-box border-box rgba(251, 249, 253, 1); width: auto; height: auto; box-shadow: 0 0 rgba(0, 0, 0, 0); display: block; overflow-x: auto; overflow-y: auto; border-top: 3px none rgba(0, 0, 0, 0.4); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px solid rgba(53, 179, 120, 1); padding: 10px 10px 10px 20px; margin: 20px 0" data-tool="mdnice编辑器">
<p style="text-indent: 0; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal; padding: 16px 0 8px; margin: 0">以下按版本逐一详述,每节包含特性表格、代码示例和分析。</p>
</blockquote>
<h2 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: flex; flex-direction: unset; float: unset; height: auto; justify-content: center; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 20px; color: rgba(255, 255, 255, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(130, 127, 196, 1); line-height: 1.5em; letter-spacing: 0; align-items: center; border-radius: 30px; box-shadow: none; display: flex; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: center; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 10px; margin: 0; border: 1px none rgba(0, 0, 0, 1)">C# 7.0:值元组</span></h2>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">特性表格</span></h3>
<section class="table-container" style="overflow-x: auto; padding: 0; margin: 0" data-tool="mdnice编辑器">
<table style="display: table; text-align: left">
<thead>
<tr>
<th style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: bold; background: none left top / auto no-repeat scroll padding-box border-box rgba(240, 240, 240, 1); width: auto; height: auto; border-radius: 0; min-width: 85px; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">类型/构造</th>
<th style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: bold; background: none left top / auto no-repeat scroll padding-box border-box rgba(240, 240, 240, 1); width: auto; height: auto; border-radius: 0; min-width: 85px; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">描述</th>
<th style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: bold; background: none left top / auto no-repeat scroll padding-box border-box rgba(240, 240, 240, 1); width: auto; height: auto; border-radius: 0; min-width: 85px; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">主要用途</th>
<th style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: bold; background: none left top / auto no-repeat scroll padding-box border-box rgba(240, 240, 240, 1); width: auto; height: auto; border-radius: 0; min-width: 85px; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">注意事项</th>
</tr>
</thead>
<tbody style="font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: normal; border-image: initial; border: 0">
<tr style="color: rgba(63, 63, 63, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(255, 255, 255, 1); width: auto; height: auto">
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">值元组 (Value Tuples)</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">轻量级值类型,支持多值返回、命名元素和解构</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">方法返回多个值、临时数据分组</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">值类型,栈分配;.NET Framework需引用System.ValueTuple包</td>
</tr>
</tbody>
</table>
</section>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">概述</span></h3>
<p style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; text-indent: 0; padding: 16px 0 8px; margin: 0" data-tool="mdnice编辑器">值元组基于<code style="color: rgba(40, 202, 113, 1); font-size: 14px; line-height: 1.8em; letter-spacing: 0; background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; height: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">System.ValueTuple</code>,允许方法返回多个值,支持命名元素和解构,简化数据传递。</p>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">语法</span></h3>
<ul style="list-style-type: disc; color: rgba(0, 0, 0, 1); padding: 0 0 0 25px; margin: 8px 0" data-tool="mdnice编辑器">
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">声明:<code style="background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">(type1, type2, ...) tupleName = (value1, value2, ...);</code></section>
</li>
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">命名元素:<code style="background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">(type1 name1, type2 name2, ...) tupleName = (value1, value2, ...);</code></section>
</li>
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">解构:<code style="background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">var (var1, var2, ...) = tupleName;</code></section>
</li>
</ul>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">示例代码</span></h3>
<pre class="language-csharp highlighter-hljs"><code>public&nbsp;(int&nbsp;id,&nbsp;string&nbsp;name)&nbsp;GetPerson()
{
&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;(1,&nbsp;"Alice");
}

var&nbsp;person&nbsp;=&nbsp;GetPerson();
Console.WriteLine($"ID:&nbsp;{person.id},&nbsp;Name:&nbsp;{person.name}");

//&nbsp;解构
var&nbsp;(id,&nbsp;name)&nbsp;=&nbsp;GetPerson();
Console.WriteLine($"ID:&nbsp;{id},&nbsp;Name:&nbsp;{name}");</code></pre>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">适用场景</span></h3>
<ul style="list-style-type: disc; color: rgba(0, 0, 0, 1); padding: 0 0 0 25px; margin: 8px 0" data-tool="mdnice编辑器">
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">方法返回多个相关值。</section>
</li>
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">临时数据分组,无需定义类或结构。</section>
</li>
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">解构赋值,简化代码。</section>
</li>
</ul>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">注意事项</span></h3>
<ul style="list-style-type: disc; color: rgba(0, 0, 0, 1); padding: 0 0 0 25px; margin: 8px 0" data-tool="mdnice编辑器">
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">值类型,适合轻量数据。</section>
</li>
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">.NET Framework项目需引用System.ValueTuple NuGet包。</section>
</li>
</ul>
<h2 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: flex; flex-direction: unset; float: unset; height: auto; justify-content: center; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 20px; color: rgba(255, 255, 255, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(130, 127, 196, 1); line-height: 1.5em; letter-spacing: 0; align-items: center; border-radius: 30px; box-shadow: none; display: flex; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: center; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 10px; margin: 0; border: 1px none rgba(0, 0, 0, 1)">C# 7.2:Span, ReadOnlySpan, 只读结构, 引用结构</span></h2>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">特性表格</span></h3>
<section class="table-container" style="overflow-x: auto; padding: 0; margin: 0" data-tool="mdnice编辑器">
<table style="display: table; text-align: left">
<thead>
<tr>
<th style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: bold; background: none left top / auto no-repeat scroll padding-box border-box rgba(240, 240, 240, 1); width: auto; height: auto; border-radius: 0; min-width: 85px; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">类型/构造</th>
<th style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: bold; background: none left top / auto no-repeat scroll padding-box border-box rgba(240, 240, 240, 1); width: auto; height: auto; border-radius: 0; min-width: 85px; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">描述</th>
<th style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: bold; background: none left top / auto no-repeat scroll padding-box border-box rgba(240, 240, 240, 1); width: auto; height: auto; border-radius: 0; min-width: 85px; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">主要用途</th>
<th style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: bold; background: none left top / auto no-repeat scroll padding-box border-box rgba(240, 240, 240, 1); width: auto; height: auto; border-radius: 0; min-width: 85px; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">注意事项</th>
</tr>
</thead>
<tbody style="font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: normal; border-image: initial; border: 0">
<tr style="color: rgba(63, 63, 63, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(255, 255, 255, 1); width: auto; height: auto">
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">Span</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">表示连续内存块的引用,支持读写</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">高性能数组/内存操作</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">ref struct,栈分配,生命周期限制</td>
</tr>
<tr style="color: rgba(0, 0, 0, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(248, 248, 248, 1); width: auto; height: auto">
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">ReadOnlySpan</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">只读连续内存块引用</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">高性能只读操作</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">同上,需确保内存边界安全</td>
</tr>
<tr style="color: rgba(63, 63, 63, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(255, 255, 255, 1); width: auto; height: auto">
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">只读结构 (readonly struct)</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">不可变结构体,优化性能</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">不可变数据结构</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">所有实例字段必须只读</td>
</tr>
<tr style="color: rgba(0, 0, 0, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(248, 248, 248, 1); width: auto; height: auto">
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">引用结构 (ref struct)</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">栈分配结构体</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">高性能内存管理</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">不可boxing或作为接口实现</td>
</tr>
</tbody>
</table>
</section>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">概述</span></h3>
<p style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; text-indent: 0; padding: 16px 0 8px; margin: 0" data-tool="mdnice编辑器"><code style="color: rgba(40, 202, 113, 1); font-size: 14px; line-height: 1.8em; letter-spacing: 0; background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; height: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">Span&lt;T&gt;</code>和<code style="color: rgba(40, 202, 113, 1); font-size: 14px; line-height: 1.8em; letter-spacing: 0; background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; height: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">ReadOnlySpan&lt;T&gt;</code>是高性能值类型,表示连续内存块引用,适合数组和本机内存操作。<code style="color: rgba(40, 202, 113, 1); font-size: 14px; line-height: 1.8em; letter-spacing: 0; background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; height: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">readonly struct</code>确保结构体不可变,<code style="color: rgba(40, 202, 113, 1); font-size: 14px; line-height: 1.8em; letter-spacing: 0; background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; height: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">ref struct</code>限制为栈分配,支持<code style="color: rgba(40, 202, 113, 1); font-size: 14px; line-height: 1.8em; letter-spacing: 0; background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; height: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">Span&lt;T&gt;</code>等类型。</p>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">语法</span></h3>
<ul style="list-style-type: disc; color: rgba(0, 0, 0, 1); padding: 0 0 0 25px; margin: 8px 0" data-tool="mdnice编辑器">
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">Span: <code style="background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">Span&lt;T&gt; span = collection.AsSpan();</code></section>
</li>
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">ReadOnlySpan: <code style="background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">ReadOnlySpan&lt;T> readOnlySpan = collection.AsSpan();</code></section>
</li>
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">只读结构: <code style="background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">readonly struct StructName { ... }</code></section>
</li>
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">引用结构: <code style="background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">ref struct StructName { ... }</code></section>
</li>
</ul>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">示例代码</span></h3>
<pre class="language-csharp highlighter-hljs"><code>//&nbsp;Span&lt;T&gt;&nbsp;和&nbsp;ReadOnlySpan&lt;T&gt;
int[]&nbsp;numbers&nbsp;=&nbsp;;
Span&lt;int&gt;&nbsp;span =&nbsp;numbers.AsSpan(1,&nbsp;3);
span&nbsp;=&nbsp;10;
Console.WriteLine(string.Join(",&nbsp;",&nbsp;span.ToArray()));&nbsp;//&nbsp;10,&nbsp;3,&nbsp;4

ReadOnlySpan&lt;char&gt;&nbsp;text&nbsp;=&nbsp;"Hello".AsSpan();
Console.WriteLine(text.Slice(0,&nbsp;2).ToString());&nbsp;//&nbsp;He

//&nbsp;只读结构
readonly&nbsp;struct&nbsp;Point
{
&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;int&nbsp;X&nbsp;{&nbsp;get;&nbsp;init;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;int&nbsp;Y&nbsp;{&nbsp;get;&nbsp;init;&nbsp;}
}
Point&nbsp;point&nbsp;=&nbsp;new()&nbsp;{&nbsp;X&nbsp;=&nbsp;1,&nbsp;Y&nbsp;=&nbsp;2&nbsp;};
Console.WriteLine($"({point.X},&nbsp;{point.Y})");&nbsp;//&nbsp;(1,&nbsp;2)

//&nbsp;引用结构
ref&nbsp;struct&nbsp;Buffer
{
&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;Span&lt;int&gt;&nbsp;Data;
&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;Buffer(Span&lt;int&gt;&nbsp;data)&nbsp;=&gt;&nbsp;Data&nbsp;=&nbsp;data;
}
Buffer&nbsp;buffer&nbsp;=&nbsp;new(numbers.AsSpan());
buffer.Data&nbsp;=&nbsp;10;
Console.WriteLine(numbers);&nbsp;//&nbsp;10</code></pre>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">适用场景</span></h3>
<ul style="list-style-type: disc; color: rgba(0, 0, 0, 1); padding: 0 0 0 25px; margin: 8px 0" data-tool="mdnice编辑器">
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">高性能字符串解析、缓冲区处理。</section>
</li>
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">不可变数据结构(只读结构)。</section>
</li>
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">避免堆分配(引用结构)。</section>
</li>
</ul>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">注意事项</span></h3>
<ul style="list-style-type: disc; color: rgba(0, 0, 0, 1); padding: 0 0 0 25px; margin: 8px 0" data-tool="mdnice编辑器">
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal"><code style="background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">Span&lt;T&gt;</code>和<code style="background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">ReadOnlySpan&lt;T&gt;</code>不可用于异步方法。</section>
</li>
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal"><code style="background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">ref struct</code>限制严格,需管理生命周期。</section>
</li>
</ul>
<h2 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: flex; flex-direction: unset; float: unset; height: auto; justify-content: center; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 20px; color: rgba(255, 255, 255, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(130, 127, 196, 1); line-height: 1.5em; letter-spacing: 0; align-items: center; border-radius: 30px; box-shadow: none; display: flex; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: center; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 10px; margin: 0; border: 1px none rgba(0, 0, 0, 1)">C# 8.0:可空引用类型, Memory, ReadOnlyMemory</span></h2>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">特性表格</span></h3>
<section class="table-container" style="overflow-x: auto; padding: 0; margin: 0" data-tool="mdnice编辑器">
<table style="display: table; text-align: left">
<thead>
<tr>
<th style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: bold; background: none left top / auto no-repeat scroll padding-box border-box rgba(240, 240, 240, 1); width: auto; height: auto; border-radius: 0; min-width: 85px; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">类型/构造</th>
<th style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: bold; background: none left top / auto no-repeat scroll padding-box border-box rgba(240, 240, 240, 1); width: auto; height: auto; border-radius: 0; min-width: 85px; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">描述</th>
<th style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: bold; background: none left top / auto no-repeat scroll padding-box border-box rgba(240, 240, 240, 1); width: auto; height: auto; border-radius: 0; min-width: 85px; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">主要用途</th>
<th style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: bold; background: none left top / auto no-repeat scroll padding-box border-box rgba(240, 240, 240, 1); width: auto; height: auto; border-radius: 0; min-width: 85px; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">注意事项</th>
</tr>
</thead>
<tbody style="font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: normal; border-image: initial; border: 0">
<tr style="color: rgba(63, 63, 63, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(255, 255, 255, 1); width: auto; height: auto">
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">可空引用类型</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">引用类型可标记为可空,默认非null</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">增强空值安全性</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">需启用可空上下文,处理编译器警告</td>
</tr>
<tr style="color: rgba(0, 0, 0, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(248, 248, 248, 1); width: auto; height: auto">
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">Memory</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">托管内存块,支持读写</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">异步和高性能内存操作</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">适合异步场景,需管理生命周期</td>
</tr>
<tr style="color: rgba(63, 63, 63, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(255, 255, 255, 1); width: auto; height: auto">
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">ReadOnlyMemory</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">只读托管内存块</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">只读异步内存操作</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">同上</td>
</tr>
</tbody>
</table>
</section>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">概述</span></h3>
<p style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; text-indent: 0; padding: 16px 0 8px; margin: 0" data-tool="mdnice编辑器">可空引用类型通过<code style="color: rgba(40, 202, 113, 1); font-size: 14px; line-height: 1.8em; letter-spacing: 0; background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; height: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">?</code>后缀指定引用类型是否可为null,减少空引用异常。<code style="color: rgba(40, 202, 113, 1); font-size: 14px; line-height: 1.8em; letter-spacing: 0; background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; height: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">Memory&lt;T&gt;</code>和<code style="color: rgba(40, 202, 113, 1); font-size: 14px; line-height: 1.8em; letter-spacing: 0; background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; height: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">ReadOnlyMemory&lt;T&gt;</code>表示托管内存块,支持异步场景。</p>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">语法</span></h3>
<ul style="list-style-type: disc; color: rgba(0, 0, 0, 1); padding: 0 0 0 25px; margin: 8px 0" data-tool="mdnice编辑器">
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">可空引用类型: <code style="background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">string? nullable; string nonNullable;</code></section>
</li>
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">Memory: <code style="background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">Memory&lt;T&gt; memory = collection.AsMemory();</code></section>
</li>
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">ReadOnlyMemory: <code style="background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">ReadOnlyMemory&lt;T&gt; readOnlyMemory = collection.AsMemory();</code></section>
</li>
</ul>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">示例代码</span></h3>
<pre class="language-csharp highlighter-hljs"><code>//&nbsp;可空引用类型
#nullable&nbsp;enable
string&nbsp;nonNullable&nbsp;=&nbsp;"Hello";
string?&nbsp;nullable&nbsp;=&nbsp;null;
if&nbsp;(nullable&nbsp;!=&nbsp;null)
{
&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(nullable.Length);
}

//&nbsp;Memory&lt;T&gt;&nbsp;和&nbsp;ReadOnlyMemory&lt;T&gt;
int[]&nbsp;numbers&nbsp;=&nbsp;;
Memory&lt;int&gt;&nbsp;memory&nbsp;=&nbsp;numbers.AsMemory(1,&nbsp;3);
Span&lt;int&gt;&nbsp;span =&nbsp;memory.Span;
span&nbsp;=&nbsp;10;
Console.WriteLine(string.Join(",&nbsp;",&nbsp;memory.ToArray()));&nbsp;//&nbsp;10,&nbsp;3,&nbsp;4

ReadOnlyMemory&lt;char&gt;&nbsp;text&nbsp;=&nbsp;"Hello".AsMemory();
Console.WriteLine(text.Slice(0,&nbsp;2).Span.ToString());&nbsp;//&nbsp;He</code></pre>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">适用场景</span></h3>
<ul style="list-style-type: disc; color: rgba(0, 0, 0, 1); padding: 0 0 0 25px; margin: 8px 0" data-tool="mdnice编辑器">
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">增强空值安全性(可空引用类型)。</section>
</li>
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">异步内存操作(Memory)。</section>
</li>
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">只读数据传递(ReadOnlyMemory)。</section>
</li>
</ul>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">注意事项</span></h3>
<ul style="list-style-type: disc; color: rgba(0, 0, 0, 1); padding: 0 0 0 25px; margin: 8px 0" data-tool="mdnice编辑器">
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">可空引用类型需显式启用。</section>
</li>
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">Memory生命周期需管理。</section>
</li>
</ul>
<h2 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: flex; flex-direction: unset; float: unset; height: auto; justify-content: center; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 20px; color: rgba(255, 255, 255, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(130, 127, 196, 1); line-height: 1.5em; letter-spacing: 0; align-items: center; border-radius: 30px; box-shadow: none; display: flex; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: center; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 10px; margin: 0; border: 1px none rgba(0, 0, 0, 1)">C# 9.0:记录, 本机大小整数, 初始化器专用类型</span></h2>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">特性表格</span></h3>
<section class="table-container" style="overflow-x: auto; padding: 0; margin: 0" data-tool="mdnice编辑器">
<table style="display: table; text-align: left">
<thead>
<tr>
<th style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: bold; background: none left top / auto no-repeat scroll padding-box border-box rgba(240, 240, 240, 1); width: auto; height: auto; border-radius: 0; min-width: 85px; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">类型/构造</th>
<th style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: bold; background: none left top / auto no-repeat scroll padding-box border-box rgba(240, 240, 240, 1); width: auto; height: auto; border-radius: 0; min-width: 85px; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">描述</th>
<th style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: bold; background: none left top / auto no-repeat scroll padding-box border-box rgba(240, 240, 240, 1); width: auto; height: auto; border-radius: 0; min-width: 85px; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">主要用途</th>
<th style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: bold; background: none left top / auto no-repeat scroll padding-box border-box rgba(240, 240, 240, 1); width: auto; height: auto; border-radius: 0; min-width: 85px; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">注意事项</th>
</tr>
</thead>
<tbody style="font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: normal; border-image: initial; border: 0">
<tr style="color: rgba(63, 63, 63, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(255, 255, 255, 1); width: auto; height: auto">
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">记录 (Records)</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">具有值语义的引用类型,默认不可变</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">数据建模,值相等性</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">默认不可变,可添加可变行为</td>
</tr>
<tr style="color: rgba(0, 0, 0, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(248, 248, 248, 1); width: auto; height: auto">
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">本机大小整数 (nint, nuint)</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">本机大小整数,映射IntPtr/UIntPtr</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">本机代码互操作</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">平台依赖,需考虑兼容性</td>
</tr>
<tr style="color: rgba(63, 63, 63, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(255, 255, 255, 1); width: auto; height: auto">
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">初始化器专用类型 (init-only setters)</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">初始化后不可变属性</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">不可变数据模型</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">仅初始化时可赋值</td>
</tr>
</tbody>
</table>
</section>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">概述</span></h3>
<p style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; text-indent: 0; padding: 16px 0 8px; margin: 0" data-tool="mdnice编辑器">记录是具有值语义的引用类型,自动实现相等性。<code style="color: rgba(40, 202, 113, 1); font-size: 14px; line-height: 1.8em; letter-spacing: 0; background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; height: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">nint</code>和<code style="color: rgba(40, 202, 113, 1); font-size: 14px; line-height: 1.8em; letter-spacing: 0; background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; height: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">nuint</code>支持本机大小整数。<code style="color: rgba(40, 202, 113, 1); font-size: 14px; line-height: 1.8em; letter-spacing: 0; background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; height: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">init</code>修饰符增强属性不可变性。</p>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">语法</span></h3>
<ul style="list-style-type: disc; color: rgba(0, 0, 0, 1); padding: 0 0 0 25px; margin: 8px 0" data-tool="mdnice编辑器">
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">记录: <code style="background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">public record ClassName(type1 Property1, ...);</code></section>
</li>
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">本机大小整数: <code style="background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">nint nativeInt; nuint nativeUInt;</code></section>
</li>
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">init-only: <code style="background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">public type Property { get; init; }</code></section>
</li>
</ul>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">示例代码</span></h3>
<pre class="language-csharp highlighter-hljs"><code>//&nbsp;记录
public&nbsp;record&nbsp;Person(string&nbsp;FirstName,&nbsp;string&nbsp;LastName);
var&nbsp;person1&nbsp;=&nbsp;new&nbsp;Person("Alice",&nbsp;"Smith");
var&nbsp;person2&nbsp;=&nbsp;new&nbsp;Person("Alice",&nbsp;"Smith");
Console.WriteLine(person1&nbsp;==&nbsp;person2);&nbsp;//&nbsp;True
var&nbsp;person3&nbsp;=&nbsp;person1&nbsp;with&nbsp;{&nbsp;LastName&nbsp;=&nbsp;"Johnson"&nbsp;};
Console.WriteLine(person3);&nbsp;//&nbsp;Person&nbsp;{&nbsp;FirstName&nbsp;=&nbsp;Alice,&nbsp;LastName&nbsp;=&nbsp;Johnson&nbsp;}

//&nbsp;本机大小整数
nint&nbsp;nativeInt&nbsp;=&nbsp;42;
nuint&nbsp;nativeUInt&nbsp;=&nbsp;42u;
Console.WriteLine($"Native&nbsp;int:&nbsp;{nativeInt},&nbsp;Native&nbsp;uint:&nbsp;{nativeUInt}");

//&nbsp;初始化器专用类型
public&nbsp;class&nbsp;Student
{
&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;string&nbsp;Name&nbsp;{&nbsp;get;&nbsp;init;&nbsp;}
}
var&nbsp;student&nbsp;=&nbsp;new&nbsp;Student&nbsp;{&nbsp;Name&nbsp;=&nbsp;"Alice"&nbsp;};
Console.WriteLine(student.Name);&nbsp;//&nbsp;Alice</code></pre>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">适用场景</span></h3>
<ul style="list-style-type: disc; color: rgba(0, 0, 0, 1); padding: 0 0 0 25px; margin: 8px 0" data-tool="mdnice编辑器">
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">数据传输对象(记录)。</section>
</li>
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">本机代码互操作(nint, nuint)。</section>
</li>
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">不可变数据模型(init-only)。</section>
</li>
</ul>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">注意事项</span></h3>
<ul style="list-style-type: disc; color: rgba(0, 0, 0, 1); padding: 0 0 0 25px; margin: 8px 0" data-tool="mdnice编辑器">
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">记录支持继承,需保持值语义。</section>
</li>
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">本机大小整数平台依赖。</section>
</li>
</ul>
<h2 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: flex; flex-direction: unset; float: unset; height: auto; justify-content: center; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 20px; color: rgba(255, 255, 255, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(130, 127, 196, 1); line-height: 1.5em; letter-spacing: 0; align-items: center; border-radius: 30px; box-shadow: none; display: flex; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: center; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 10px; margin: 0; border: 1px none rgba(0, 0, 0, 1)">C# 10.0:记录结构, 全局 using 指令</span></h2>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">特性表格</span></h3>
<section class="table-container" style="overflow-x: auto; padding: 0; margin: 0" data-tool="mdnice编辑器">
<table style="display: table; text-align: left">
<thead>
<tr>
<th style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: bold; background: none left top / auto no-repeat scroll padding-box border-box rgba(240, 240, 240, 1); width: auto; height: auto; border-radius: 0; min-width: 85px; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">类型/构造</th>
<th style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: bold; background: none left top / auto no-repeat scroll padding-box border-box rgba(240, 240, 240, 1); width: auto; height: auto; border-radius: 0; min-width: 85px; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">描述</th>
<th style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: bold; background: none left top / auto no-repeat scroll padding-box border-box rgba(240, 240, 240, 1); width: auto; height: auto; border-radius: 0; min-width: 85px; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">主要用途</th>
<th style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: bold; background: none left top / auto no-repeat scroll padding-box border-box rgba(240, 240, 240, 1); width: auto; height: auto; border-radius: 0; min-width: 85px; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">注意事项</th>
</tr>
</thead>
<tbody style="font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: normal; border-image: initial; border: 0">
<tr style="color: rgba(63, 63, 63, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(255, 255, 255, 1); width: auto; height: auto">
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">记录结构 (Record Structs)</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">值类型的记录,结合值语义和性能</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">小型数据结构</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">值类型,复制成本需考虑</td>
</tr>
<tr style="color: rgba(0, 0, 0, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(248, 248, 248, 1); width: auto; height: auto">
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">全局 using 指令</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">全局导入命名空间</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">简化类型引用</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">需平衡代码可读性</td>
</tr>
</tbody>
</table>
</section>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">概述</span></h3>
<p style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; text-indent: 0; padding: 16px 0 8px; margin: 0" data-tool="mdnice编辑器">记录结构将记录特性扩展到值类型,结合值语义和性能。全局<code style="color: rgba(40, 202, 113, 1); font-size: 14px; line-height: 1.8em; letter-spacing: 0; background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; height: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">using</code>简化类型引用。</p>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">语法</span></h3>
<ul style="list-style-type: disc; color: rgba(0, 0, 0, 1); padding: 0 0 0 25px; margin: 8px 0" data-tool="mdnice编辑器">
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">记录结构: <code style="background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">public record struct StructName(type1 Property1, ...);</code></section>
</li>
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">全局 using: <code style="background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">global using System;</code></section>
</li>
</ul>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">示例代码</span></h3>
<pre class="language-csharp highlighter-hljs"><code>//&nbsp;记录结构
public&nbsp;record&nbsp;struct&nbsp;Point(int&nbsp;X,&nbsp;int&nbsp;Y);
var&nbsp;point1&nbsp;=&nbsp;new&nbsp;Point(1,&nbsp;2);
var&nbsp;point2&nbsp;=&nbsp;new&nbsp;Point(1,&nbsp;2);
Console.WriteLine(point1&nbsp;==&nbsp;point2);&nbsp;//&nbsp;True
var&nbsp;point3&nbsp;=&nbsp;point1&nbsp;with&nbsp;{&nbsp;X&nbsp;=&nbsp;3&nbsp;};
Console.WriteLine(point3);&nbsp;//&nbsp;Point&nbsp;{&nbsp;X&nbsp;=&nbsp;3,&nbsp;Y&nbsp;=&nbsp;2&nbsp;}

//&nbsp;全局&nbsp;using(假设已在文件顶部)
Console.WriteLine("Hello,&nbsp;World!");&nbsp;//&nbsp;无需显式&nbsp;using&nbsp;System</code></pre>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">适用场景</span></h3>
<ul style="list-style-type: disc; color: rgba(0, 0, 0, 1); padding: 0 0 0 25px; margin: 8px 0" data-tool="mdnice编辑器">
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">值类型数据建模(记录结构)。</section>
</li>
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">大型项目命名空间管理(全局 using)。</section>
</li>
</ul>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">注意事项</span></h3>
<ul style="list-style-type: disc; color: rgba(0, 0, 0, 1); padding: 0 0 0 25px; margin: 8px 0" data-tool="mdnice编辑器">
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">记录结构复制成本需关注。</section>
</li>
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">全局 using 需谨慎使用。</section>
</li>
</ul>
<h2 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: flex; flex-direction: unset; float: unset; height: auto; justify-content: center; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 20px; color: rgba(255, 255, 255, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(130, 127, 196, 1); line-height: 1.5em; letter-spacing: 0; align-items: center; border-radius: 30px; box-shadow: none; display: flex; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: center; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 10px; margin: 0; border: 1px none rgba(0, 0, 0, 1)">C# 11.0:必需成员, 泛型数学支持, 文件局部类型</span></h2>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">特性表格</span></h3>
<section class="table-container" style="overflow-x: auto; padding: 0; margin: 0" data-tool="mdnice编辑器">
<table style="display: table; text-align: left">
<thead>
<tr>
<th style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: bold; background: none left top / auto no-repeat scroll padding-box border-box rgba(240, 240, 240, 1); width: auto; height: auto; border-radius: 0; min-width: 85px; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">类型/构造</th>
<th style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: bold; background: none left top / auto no-repeat scroll padding-box border-box rgba(240, 240, 240, 1); width: auto; height: auto; border-radius: 0; min-width: 85px; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">描述</th>
<th style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: bold; background: none left top / auto no-repeat scroll padding-box border-box rgba(240, 240, 240, 1); width: auto; height: auto; border-radius: 0; min-width: 85px; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">主要用途</th>
<th style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: bold; background: none left top / auto no-repeat scroll padding-box border-box rgba(240, 240, 240, 1); width: auto; height: auto; border-radius: 0; min-width: 85px; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">注意事项</th>
</tr>
</thead>
<tbody style="font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: normal; border-image: initial; border: 0">
<tr style="color: rgba(63, 63, 63, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(255, 255, 255, 1); width: auto; height: auto">
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">必需成员 (required members)</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">强制成员初始化</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">确保关键字段初始化</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">需配合初始化器或构造函数</td>
</tr>
<tr style="color: rgba(0, 0, 0, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(248, 248, 248, 1); width: auto; height: auto">
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">泛型数学支持</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">静态抽象接口成员支持泛型运算</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">泛型算法库</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">需运行时支持(.NET 7+)</td>
</tr>
<tr style="color: rgba(63, 63, 63, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(255, 255, 255, 1); width: auto; height: auto">
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">文件局部类型 (file modifier)</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">限制类型作用域至文件</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">隔离辅助类型</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">仅限文件作用域</td>
</tr>
</tbody>
</table>
</section>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">概述</span></h3>
<p style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; text-indent: 0; padding: 16px 0 8px; margin: 0" data-tool="mdnice编辑器"><code style="color: rgba(40, 202, 113, 1); font-size: 14px; line-height: 1.8em; letter-spacing: 0; background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; height: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">required</code>修饰符强制成员初始化。泛型数学支持通过接口实现数值运算。<code style="color: rgba(40, 202, 113, 1); font-size: 14px; line-height: 1.8em; letter-spacing: 0; background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; height: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">file</code>修饰符限制类型作用域。</p>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">语法</span></h3>
<ul style="list-style-type: disc; color: rgba(0, 0, 0, 1); padding: 0 0 0 25px; margin: 8px 0" data-tool="mdnice编辑器">
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">必需成员: <code style="background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">public required type Property { get; set; }</code></section>
</li>
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">泛型数学: <code style="background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">interface INumber&lt;T&gt; { static abstract T operator +(T, T); }</code></section>
</li>
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">文件局部类型: <code style="background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">file class ClassName { ... }</code></section>
</li>
</ul>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">示例代码</span></h3>
<pre class="language-csharp highlighter-hljs"><code>//&nbsp;必需成员
public&nbsp;class&nbsp;Person
{
&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;required&nbsp;string&nbsp;Name&nbsp;{&nbsp;get;&nbsp;set;&nbsp;}
}
var&nbsp;person&nbsp;=&nbsp;new&nbsp;Person&nbsp;{&nbsp;Name&nbsp;=&nbsp;"Alice"&nbsp;};
Console.WriteLine(person.Name);&nbsp;//&nbsp;Alice

//&nbsp;泛型数学支持
public&nbsp;interface&nbsp;INumber&lt;T&gt;&nbsp;where&nbsp;T&nbsp;:&nbsp;INumber&lt;T&gt;
{
&nbsp;&nbsp;&nbsp;&nbsp;static&nbsp;abstract&nbsp;T&nbsp;Add(T&nbsp;left,&nbsp;T&nbsp;right);
}
public&nbsp;readonly&nbsp;struct&nbsp;MyNumber&nbsp;:&nbsp;INumber&lt;MyNumber&gt;
{
&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;int&nbsp;Value&nbsp;{&nbsp;get;&nbsp;init;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;MyNumber(int&nbsp;value)&nbsp;=&gt;&nbsp;Value&nbsp;=&nbsp;value;
&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;static&nbsp;MyNumber&nbsp;Add(MyNumber&nbsp;left,&nbsp;MyNumber&nbsp;right)&nbsp;=&gt;&nbsp;new(left.Value&nbsp;+&nbsp;right.Value);
}
MyNumber&nbsp;a&nbsp;=&nbsp;new(1);
MyNumber&nbsp;b&nbsp;=&nbsp;new(2);
var&nbsp;result&nbsp;=&nbsp;MyNumber.Add(a,&nbsp;b);
Console.WriteLine(result.Value);&nbsp;//&nbsp;3

//&nbsp;文件局部类型
file&nbsp;class&nbsp;Helper
{
&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;static&nbsp;void&nbsp;Log(string&nbsp;message)&nbsp;=&gt;&nbsp;Console.WriteLine(message);
}
Helper.Log("Test");</code></pre>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">适用场景</span></h3>
<ul style="list-style-type: disc; color: rgba(0, 0, 0, 1); padding: 0 0 0 25px; margin: 8px 0" data-tool="mdnice编辑器">
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">API 设计(必需成员)。</section>
</li>
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">泛型数值计算(泛型数学)。</section>
</li>
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">代码生成(文件局部类型)。</section>
</li>
</ul>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">注意事项</span></h3>
<ul style="list-style-type: disc; color: rgba(0, 0, 0, 1); padding: 0 0 0 25px; margin: 8px 0" data-tool="mdnice编辑器">
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">必需成员需明确初始化。</section>
</li>
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">泛型数学需运行时支持。</section>
</li>
</ul>
<h2 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: flex; flex-direction: unset; float: unset; height: auto; justify-content: center; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 20px; color: rgba(255, 255, 255, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(130, 127, 196, 1); line-height: 1.5em; letter-spacing: 0; align-items: center; border-radius: 30px; box-shadow: none; display: flex; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: center; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 10px; margin: 0; border: 1px none rgba(0, 0, 0, 1)">C# 12.0:内联数组</span></h2>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">特性表格</span></h3>
<section class="table-container" style="overflow-x: auto; padding: 0; margin: 0" data-tool="mdnice编辑器">
<table style="display: table; text-align: left">
<thead>
<tr>
<th style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: bold; background: none left top / auto no-repeat scroll padding-box border-box rgba(240, 240, 240, 1); width: auto; height: auto; border-radius: 0; min-width: 85px; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">类型/构造</th>
<th style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: bold; background: none left top / auto no-repeat scroll padding-box border-box rgba(240, 240, 240, 1); width: auto; height: auto; border-radius: 0; min-width: 85px; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">描述</th>
<th style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: bold; background: none left top / auto no-repeat scroll padding-box border-box rgba(240, 240, 240, 1); width: auto; height: auto; border-radius: 0; min-width: 85px; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">主要用途</th>
<th style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: bold; background: none left top / auto no-repeat scroll padding-box border-box rgba(240, 240, 240, 1); width: auto; height: auto; border-radius: 0; min-width: 85px; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">注意事项</th>
</tr>
</thead>
<tbody style="font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: normal; border-image: initial; border: 0">
<tr style="color: rgba(63, 63, 63, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(255, 255, 255, 1); width: auto; height: auto">
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">内联数组 (Inline Arrays)</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">固定大小数组结构,栈分配</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">高性能固定大小数组</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">固定大小,仅限结构体内</td>
</tr>
</tbody>
</table>
</section>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">概述</span></h3>
<p style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; text-indent: 0; padding: 16px 0 8px; margin: 0" data-tool="mdnice编辑器">内联数组通过<code style="color: rgba(40, 202, 113, 1); font-size: 14px; line-height: 1.8em; letter-spacing: 0; background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; height: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px"></code>特性定义固定大小数组结构,优化性能。</p>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">语法</span></h3>
<pre class="language-csharp highlighter-hljs"><code>
public&nbsp;struct&nbsp;StructName
{
&nbsp;&nbsp;&nbsp;&nbsp;private&nbsp;elementType&nbsp;_element0;
}</code></pre>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">示例代码</span></h3>
<pre class="language-csharp highlighter-hljs"><code>
public&nbsp;struct&nbsp;Buffer
{
&nbsp;&nbsp;&nbsp;&nbsp;private&nbsp;int&nbsp;_element0;
}
Buffer&nbsp;buffer&nbsp;=&nbsp;new();
buffer&nbsp;=&nbsp;1;
buffer&nbsp;=&nbsp;10;
Console.WriteLine(buffer);&nbsp;//&nbsp;1</code></pre>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">适用场景</span></h3>
<ul style="list-style-type: disc; color: rgba(0, 0, 0, 1); padding: 0 0 0 25px; margin: 8px 0" data-tool="mdnice编辑器">
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">高性能计算。</section>
</li>
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">替代不安全固定缓冲区。</section>
</li>
</ul>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">注意事项</span></h3>
<ul style="list-style-type: disc; color: rgba(0, 0, 0, 1); padding: 0 0 0 25px; margin: 8px 0" data-tool="mdnice编辑器">
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">固定大小,运行时不可调整。</section>
</li>
</ul>
<h2 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: flex; flex-direction: unset; float: unset; height: auto; justify-content: center; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 20px; color: rgba(255, 255, 255, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(130, 127, 196, 1); line-height: 1.5em; letter-spacing: 0; align-items: center; border-radius: 30px; box-shadow: none; display: flex; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: center; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 10px; margin: 0; border: 1px none rgba(0, 0, 0, 1)">C# 13.0:参数集合扩展, 引用结构接口支持, 部分属性</span></h2>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">特性表格</span></h3>
<section class="table-container" style="overflow-x: auto; padding: 0; margin: 0" data-tool="mdnice编辑器">
<table style="display: table; text-align: left">
<thead>
<tr>
<th style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: bold; background: none left top / auto no-repeat scroll padding-box border-box rgba(240, 240, 240, 1); width: auto; height: auto; border-radius: 0; min-width: 85px; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">类型/构造</th>
<th style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: bold; background: none left top / auto no-repeat scroll padding-box border-box rgba(240, 240, 240, 1); width: auto; height: auto; border-radius: 0; min-width: 85px; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">描述</th>
<th style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: bold; background: none left top / auto no-repeat scroll padding-box border-box rgba(240, 240, 240, 1); width: auto; height: auto; border-radius: 0; min-width: 85px; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">主要用途</th>
<th style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: bold; background: none left top / auto no-repeat scroll padding-box border-box rgba(240, 240, 240, 1); width: auto; height: auto; border-radius: 0; min-width: 85px; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">注意事项</th>
</tr>
</thead>
<tbody style="font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: normal; border-image: initial; border: 0">
<tr style="color: rgba(63, 63, 63, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(255, 255, 255, 1); width: auto; height: auto">
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">参数集合扩展 (params Span等)</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">扩展params支持Span等</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">高性能参数传递</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">需确保Span生命周期</td>
</tr>
<tr style="color: rgba(0, 0, 0, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(248, 248, 248, 1); width: auto; height: auto">
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">引用结构接口支持</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">允许ref struct实现接口</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">扩展ref struct能力</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">仍受ref struct限制</td>
</tr>
<tr style="color: rgba(63, 63, 63, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(255, 255, 255, 1); width: auto; height: auto">
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">部分属性 (partial properties)</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">支持partial类型部分属性</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">代码生成</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">需确保定义一致</td>
</tr>
</tbody>
</table>
</section>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">概述</span></h3>
<p style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; text-indent: 0; padding: 16px 0 8px; margin: 0" data-tool="mdnice编辑器">参数集合扩展支持<code style="color: rgba(40, 202, 113, 1); font-size: 14px; line-height: 1.8em; letter-spacing: 0; background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; height: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">Span&lt;T&gt;</code>等类型。<code style="color: rgba(40, 202, 113, 1); font-size: 14px; line-height: 1.8em; letter-spacing: 0; background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; height: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">ref struct</code>可实现接口。部分属性支持分文件定义。</p>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">语法</span></h3>
<ul style="list-style-type: disc; color: rgba(0, 0, 0, 1); padding: 0 0 0 25px; margin: 8px 0" data-tool="mdnice编辑器">
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">参数集合: <code style="background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">void Method(params Span&lt;T&gt; spans);</code></section>
</li>
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">引用结构接口: <code style="background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">ref struct StructName : IInterface { ... }</code></section>
</li>
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">部分属性: <code style="background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">public partial type Property { get; set; }</code></section>
</li>
</ul>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">示例代码</span></h3>
<pre class="language-csharp highlighter-hljs"><code>//&nbsp;参数集合扩展
public&nbsp;void&nbsp;Process(params&nbsp;Span&lt;int&gt;&nbsp;spans)
{
&nbsp;&nbsp;&nbsp;&nbsp;foreach&nbsp;(var&nbsp;span in&nbsp;spans)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(string.Join(",&nbsp;",&nbsp;span.ToArray()));
}
int[]&nbsp;numbers&nbsp;=&nbsp;;
Process(numbers.AsSpan(0,&nbsp;2),&nbsp;numbers.AsSpan(2,&nbsp;1));&nbsp;//&nbsp;1,&nbsp;2&nbsp;和&nbsp;3

//&nbsp;引用结构接口支持
public&nbsp;interface&nbsp;IBuffer
{
&nbsp;&nbsp;&nbsp;&nbsp;void&nbsp;Process();
}
ref&nbsp;struct&nbsp;Buffer&nbsp;:&nbsp;IBuffer
{
&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;Span&lt;int&gt;&nbsp;Data;
&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;Buffer(Span&lt;int&gt;&nbsp;data)&nbsp;=&gt;&nbsp;Data&nbsp;=&nbsp;data;
&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;void&nbsp;Process()&nbsp;=&gt;&nbsp;Data&nbsp;=&nbsp;10;
}
Buffer&nbsp;buffer&nbsp;=&nbsp;new(numbers.AsSpan());
buffer.Process();
Console.WriteLine(numbers);&nbsp;//&nbsp;10

//&nbsp;部分属性
public&nbsp;partial&nbsp;class&nbsp;Person
{
&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;partial&nbsp;string&nbsp;Name&nbsp;{&nbsp;get;&nbsp;set;&nbsp;}
}
public&nbsp;partial&nbsp;class&nbsp;Person
{
&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;partial&nbsp;string&nbsp;Name&nbsp;{&nbsp;get&nbsp;=&gt;&nbsp;_name;&nbsp;set&nbsp;=&gt;&nbsp;_name&nbsp;=&nbsp;value;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;private&nbsp;string&nbsp;_name;
}
var&nbsp;person&nbsp;=&nbsp;new&nbsp;Person&nbsp;{&nbsp;Name&nbsp;=&nbsp;"Alice"&nbsp;};
Console.WriteLine(person.Name);&nbsp;//&nbsp;Alice</code></pre>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">适用场景</span></h3>
<ul style="list-style-type: disc; color: rgba(0, 0, 0, 1); padding: 0 0 0 25px; margin: 8px 0" data-tool="mdnice编辑器">
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">高性能参数传递(参数集合)。</section>
</li>
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">扩展<code style="background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">ref struct</code>(接口支持)。</section>
</li>
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">代码生成(部分属性)。</section>
</li>
</ul>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">注意事项</span></h3>
<ul style="list-style-type: disc; color: rgba(0, 0, 0, 1); padding: 0 0 0 25px; margin: 8px 0" data-tool="mdnice编辑器">
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">参数集合需管理Span生命周期。</section>
</li>
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">部分属性需确保一致性。</section>
</li>
</ul>
<h2 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: flex; flex-direction: unset; float: unset; height: auto; justify-content: center; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 20px; color: rgba(255, 255, 255, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(130, 127, 196, 1); line-height: 1.5em; letter-spacing: 0; align-items: center; border-radius: 30px; box-shadow: none; display: flex; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: center; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 10px; margin: 0; border: 1px none rgba(0, 0, 0, 1)">C# 14.0:<code>field</code> 关键字, 隐式 span 转换, <code>nameof</code> 增强, lambda 参数修饰符, partial 成员扩展, 空条件赋值</span></h2>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">特性表格</span></h3>
<section class="table-container" style="overflow-x: auto; padding: 0; margin: 0" data-tool="mdnice编辑器">
<table style="display: table; text-align: left">
<thead>
<tr>
<th style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: bold; background: none left top / auto no-repeat scroll padding-box border-box rgba(240, 240, 240, 1); width: auto; height: auto; border-radius: 0; min-width: 85px; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">类型/构造</th>
<th style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: bold; background: none left top / auto no-repeat scroll padding-box border-box rgba(240, 240, 240, 1); width: auto; height: auto; border-radius: 0; min-width: 85px; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">描述</th>
<th style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: bold; background: none left top / auto no-repeat scroll padding-box border-box rgba(240, 240, 240, 1); width: auto; height: auto; border-radius: 0; min-width: 85px; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">主要用途</th>
<th style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: bold; background: none left top / auto no-repeat scroll padding-box border-box rgba(240, 240, 240, 1); width: auto; height: auto; border-radius: 0; min-width: 85px; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">注意事项</th>
</tr>
</thead>
<tbody style="font-size: 16px; line-height: 1.5em; letter-spacing: 0.02em; text-align: left; font-weight: normal; border-image: initial; border: 0">
<tr style="color: rgba(63, 63, 63, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(255, 255, 255, 1); width: auto; height: auto">
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px"><code>field</code> 关键字</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">允许在属性访问器中直接访问 backing field</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">简化属性实现</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">可能与现有字段名冲突,需使用 <code>@field</code> 或 <code>this.field</code> 区分</td>
</tr>
<tr style="color: rgba(0, 0, 0, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(248, 248, 248, 1); width: auto; height: auto">
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">隐式 span 转换</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">支持 <code>Span&lt;T&gt;</code>、<code>ReadOnlySpan&lt;T&gt;</code> 与数组间的隐式转换</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">更自然地使用 span 类型</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">需注意 span 的生命周期</td>
</tr>
<tr style="color: rgba(63, 63, 63, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(255, 255, 255, 1); width: auto; height: auto">
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px"><code>nameof</code> 支持未绑定泛型</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">允许 <code>nameof</code> 使用未绑定泛型类型,如 <code>nameof(List&lt;&gt;)</code></td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">泛型编程中的类型名称获取</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">-</td>
</tr>
<tr style="color: rgba(0, 0, 0, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(248, 248, 248, 1); width: auto; height: auto">
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">lambda 参数修饰符</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">允许 lambda 参数使用 <code>ref</code>、<code>out</code> 等修饰符,无需指定类型</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">增强 lambda 表达式的灵活性</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px"><code>params</code> 仍需指定类型</td>
</tr>
<tr style="color: rgba(63, 63, 63, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(255, 255, 255, 1); width: auto; height: auto">
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">partial 构造函数和事件</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">扩展 partial 成员到实例构造函数和事件</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">分离定义和实现,适合代码生成</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">需确保 defining 和 implementing 声明一致</td>
</tr>
<tr style="color: rgba(0, 0, 0, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(248, 248, 248, 1); width: auto; height: auto">
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">空条件赋值</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">允许在赋值左侧使用 <code>?.</code> 和 <code>?[]</code>,仅在左侧非 null 时赋值</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">简化 null 检查</td>
<td style="min-width: 85px; border-radius: 0; border: 1px solid rgba(204, 204, 204, 0.4); padding: 5px 10px">不支持 <code>++</code> 和 <code>--</code></td>
</tr>
</tbody>
</table>
</section>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">概述</span></h3>
<p style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; text-indent: 0; padding: 16px 0 8px; margin: 0" data-tool="mdnice编辑器">C# 14.0(预计2025年随.NET 10发布,截至2025年4月为预览版)引入了一系列语言特性,旨在提高开发效率和代码可读性,包括 <code style="color: rgba(40, 202, 113, 1); font-size: 14px; line-height: 1.8em; letter-spacing: 0; background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; height: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">field</code> 关键字、隐式 span 转换、<code style="color: rgba(40, 202, 113, 1); font-size: 14px; line-height: 1.8em; letter-spacing: 0; background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; height: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">nameof</code> 增强、lambda 参数修饰符、partial 成员扩展和空条件赋值。虽然未引入全新数据类型,但这些特性显著增强了现有类型的用法。</p>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0"><code>field</code> 关键字</span></h3>
<h4 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 16px; color: rgba(60, 112, 198, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 0 0 0 8px; border: 1px none rgba(0, 0, 0, 1)">概述</span></h4>
<p style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; text-indent: 0; padding: 16px 0 8px; margin: 0" data-tool="mdnice编辑器"><code style="color: rgba(40, 202, 113, 1); font-size: 14px; line-height: 1.8em; letter-spacing: 0; background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; height: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">field</code> 关键字允许在属性访问器中直接访问编译器生成的 backing field,无需显式声明。</p>
<h4 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 16px; color: rgba(60, 112, 198, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 0 0 0 8px; border: 1px none rgba(0, 0, 0, 1)">示例代码</span></h4>
<pre class="language-csharp highlighter-hljs"><code>public&nbsp;class&nbsp;Person
{
&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;string&nbsp;Name
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;get&nbsp;=&gt;&nbsp;field;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set&nbsp;=&gt;&nbsp;field&nbsp;=&nbsp;value?.Trim();
&nbsp;&nbsp;&nbsp;&nbsp;}
}
var&nbsp;person&nbsp;=&nbsp;new&nbsp;Person&nbsp;{&nbsp;Name&nbsp;=&nbsp;"&nbsp;Alice&nbsp;"&nbsp;};
Console.WriteLine(person.Name);&nbsp;//&nbsp;Alice</code></pre>
<h4 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 16px; color: rgba(60, 112, 198, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 0 0 0 8px; border: 1px none rgba(0, 0, 0, 1)">适用场景</span></h4>
<ul style="list-style-type: disc; color: rgba(0, 0, 0, 1); padding: 0 0 0 25px; margin: 8px 0" data-tool="mdnice编辑器">
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">简化属性实现,特别是需要对 setter 进行处理时。</section>
</li>
</ul>
<h4 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 16px; color: rgba(60, 112, 198, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 0 0 0 8px; border: 1px none rgba(0, 0, 0, 1)">注意事项</span></h4>
<ul style="list-style-type: disc; color: rgba(0, 0, 0, 1); padding: 0 0 0 25px; margin: 8px 0" data-tool="mdnice编辑器">
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">如果类中已有名为 <code style="background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">field</code> 的字段,需使用 <code style="background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">@field</code> 或 <code style="background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">this.field</code> 区分。</section>
</li>
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">作为C# 13.0的预览特性,C# 14.0正式支持,详见field 关键字。</section>
</li>
</ul>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">隐式 span 转换</span></h3>
<h4 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 16px; color: rgba(60, 112, 198, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 0 0 0 8px; border: 1px none rgba(0, 0, 0, 1)">概述</span></h4>
<p style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; text-indent: 0; padding: 16px 0 8px; margin: 0" data-tool="mdnice编辑器">C# 14.0 为 <code style="color: rgba(40, 202, 113, 1); font-size: 14px; line-height: 1.8em; letter-spacing: 0; background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; height: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">Span&lt;T&gt;</code> 和 <code style="color: rgba(40, 202, 113, 1); font-size: 14px; line-height: 1.8em; letter-spacing: 0; background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; height: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">ReadOnlySpan&lt;T&gt;</code> 提供了与数组的隐式转换,使其使用更加自然。</p>
<h4 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 16px; color: rgba(60, 112, 198, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 0 0 0 8px; border: 1px none rgba(0, 0, 0, 1)">示例代码</span></h4>
<pre class="language-php highlighter-hljs"><code>Span&lt;int&gt;&nbsp;span =&nbsp;new&nbsp;int[]&nbsp;{1,&nbsp;2,&nbsp;3};
int[]&nbsp;array&nbsp;=&nbsp;span.ToArray();
Console.WriteLine(string.Join(",&nbsp;",&nbsp;array));&nbsp;//&nbsp;1,&nbsp;2,&nbsp;3</code></pre>
<h4 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 16px; color: rgba(60, 112, 198, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 0 0 0 8px; border: 1px none rgba(0, 0, 0, 1)">适用场景</span></h4>
<ul style="list-style-type: disc; color: rgba(0, 0, 0, 1); padding: 0 0 0 25px; margin: 8px 0" data-tool="mdnice编辑器">
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">高性能场景中,减少显式转换。</section>
</li>
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">与数组和 span 类型交互。</section>
</li>
</ul>
<h4 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 16px; color: rgba(60, 112, 198, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 0 0 0 8px; border: 1px none rgba(0, 0, 0, 1)">注意事项</span></h4>
<ul style="list-style-type: disc; color: rgba(0, 0, 0, 1); padding: 0 0 0 25px; margin: 8px 0" data-tool="mdnice编辑器">
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">需确保 span 的生命周期管理,详见Span 转换。</section>
</li>
</ul>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0"><code>nameof</code> 支持未绑定泛型</span></h3>
<h4 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 16px; color: rgba(60, 112, 198, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 0 0 0 8px; border: 1px none rgba(0, 0, 0, 1)">概述</span></h4>
<p style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; text-indent: 0; padding: 16px 0 8px; margin: 0" data-tool="mdnice编辑器">允许 <code style="color: rgba(40, 202, 113, 1); font-size: 14px; line-height: 1.8em; letter-spacing: 0; background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; height: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">nameof</code> 操作符使用未绑定泛型类型。</p>
<h4 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 16px; color: rgba(60, 112, 198, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 0 0 0 8px; border: 1px none rgba(0, 0, 0, 1)">示例代码</span></h4>
<pre class="language-csharp highlighter-hljs"><code>string&nbsp;listName&nbsp;=&nbsp;nameof(List&lt;&gt;);
Console.WriteLine(listName);&nbsp;//&nbsp;List</code></pre>
<h4 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 16px; color: rgba(60, 112, 198, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 0 0 0 8px; border: 1px none rgba(0, 0, 0, 1)">适用场景</span></h4>
<ul style="list-style-type: disc; color: rgba(0, 0, 0, 1); padding: 0 0 0 25px; margin: 8px 0" data-tool="mdnice编辑器">
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">泛型编程中,获取类型名称。</section>
</li>
</ul>
<h4 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 16px; color: rgba(60, 112, 198, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 0 0 0 8px; border: 1px none rgba(0, 0, 0, 1)">注意事项</span></h4>
<ul style="list-style-type: disc; color: rgba(0, 0, 0, 1); padding: 0 0 0 25px; margin: 8px 0" data-tool="mdnice编辑器">
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">简单但强大的增强,适合反射场景。</section>
</li>
</ul>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">lambda 参数修饰符</span></h3>
<h4 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 16px; color: rgba(60, 112, 198, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 0 0 0 8px; border: 1px none rgba(0, 0, 0, 1)">概述</span></h4>
<p style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; text-indent: 0; padding: 16px 0 8px; margin: 0" data-tool="mdnice编辑器">允许在 lambda 表达式中为参数添加修饰符,如 <code style="color: rgba(40, 202, 113, 1); font-size: 14px; line-height: 1.8em; letter-spacing: 0; background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; height: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">ref</code>、<code style="color: rgba(40, 202, 113, 1); font-size: 14px; line-height: 1.8em; letter-spacing: 0; background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; height: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">out</code> 等,无需指定类型。</p>
<h4 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 16px; color: rgba(60, 112, 198, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 0 0 0 8px; border: 1px none rgba(0, 0, 0, 1)">示例代码</span></h4>
<pre class="language-dart highlighter-hljs"><code>var&nbsp;increment&nbsp;=&nbsp;(ref&nbsp;int&nbsp;x)&nbsp;=&gt;&nbsp;x++;
int&nbsp;num&nbsp;=&nbsp;5;
increment(ref&nbsp;num);
Console.WriteLine(num);&nbsp;//&nbsp;6</code></pre>
<h4 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 16px; color: rgba(60, 112, 198, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 0 0 0 8px; border: 1px none rgba(0, 0, 0, 1)">适用场景</span></h4>
<ul style="list-style-type: disc; color: rgba(0, 0, 0, 1); padding: 0 0 0 25px; margin: 8px 0" data-tool="mdnice编辑器">
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">需要在 lambda 中修改外部变量。</section>
</li>
</ul>
<h4 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 16px; color: rgba(60, 112, 198, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 0 0 0 8px; border: 1px none rgba(0, 0, 0, 1)">注意事项</span></h4>
<ul style="list-style-type: disc; color: rgba(0, 0, 0, 1); padding: 0 0 0 25px; margin: 8px 0" data-tool="mdnice编辑器">
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal"><code style="background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">params</code> 仍需指定类型,详见lambda 表达式。</section>
</li>
</ul>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">partial 构造函数和事件</span></h3>
<h4 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 16px; color: rgba(60, 112, 198, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 0 0 0 8px; border: 1px none rgba(0, 0, 0, 1)">概述</span></h4>
<p style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; text-indent: 0; padding: 16px 0 8px; margin: 0" data-tool="mdnice编辑器">扩展 partial 成员到实例构造函数和事件,允许在 partial 类型中分离定义和实现。</p>
<h4 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 16px; color: rgba(60, 112, 198, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 0 0 0 8px; border: 1px none rgba(0, 0, 0, 1)">示例代码</span></h4>
<pre class="language-csharp highlighter-hljs"><code>//&nbsp;File1.cs
public&nbsp;partial&nbsp;class&nbsp;MyClass
{
&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;partial&nbsp;MyClass(int&nbsp;x);
&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;partial&nbsp;event&nbsp;EventHandler&nbsp;MyEvent;
}

//&nbsp;File2.cs
public&nbsp;partial&nbsp;class&nbsp;MyClass
{
&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;partial&nbsp;MyClass(int&nbsp;x)&nbsp;{&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;partial&nbsp;event&nbsp;EventHandler&nbsp;MyEvent;
}</code></pre>
<h4 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 16px; color: rgba(60, 112, 198, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 0 0 0 8px; border: 1px none rgba(0, 0, 0, 1)">适用场景</span></h4>
<ul style="list-style-type: disc; color: rgba(0, 0, 0, 1); padding: 0 0 0 25px; margin: 8px 0" data-tool="mdnice编辑器">
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">代码生成场景,如 UI 设计器。</section>
</li>
</ul>
<h4 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 16px; color: rgba(60, 112, 198, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 0 0 0 8px; border: 1px none rgba(0, 0, 0, 1)">注意事项</span></h4>
<ul style="list-style-type: disc; color: rgba(0, 0, 0, 1); padding: 0 0 0 25px; margin: 8px 0" data-tool="mdnice编辑器">
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">需确保 defining 和 implementing 声明一致,详见partial 成员。</section>
</li>
</ul>
<h3 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 18px; color: rgba(37, 181, 44, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; border-top: 1px none rgba(0, 0, 0, 1); border-right: 1px none rgba(0, 0, 0, 1); border-bottom: 2px solid rgba(37, 181, 44, 1); border-left: 1px none rgba(0, 0, 0, 1); padding: 2px 10px; margin: 0">空条件赋值</span></h3>
<h4 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 16px; color: rgba(60, 112, 198, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 0 0 0 8px; border: 1px none rgba(0, 0, 0, 1)">概述</span></h4>
<p style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; text-indent: 0; padding: 16px 0 8px; margin: 0" data-tool="mdnice编辑器">允许在赋值语句的左侧使用 <code style="color: rgba(40, 202, 113, 1); font-size: 14px; line-height: 1.8em; letter-spacing: 0; background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; height: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">?.</code> 和 <code style="color: rgba(40, 202, 113, 1); font-size: 14px; line-height: 1.8em; letter-spacing: 0; background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; height: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">?[]</code>,仅当左侧非 null 时执行赋值。</p>
<h4 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 16px; color: rgba(60, 112, 198, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 0 0 0 8px; border: 1px none rgba(0, 0, 0, 1)">示例代码</span></h4>
<pre class="language-csharp highlighter-hljs"><code>string?&nbsp;text&nbsp;=&nbsp;null;
text?.Length&nbsp;=&nbsp;5;&nbsp;//&nbsp;不执行赋值

List&lt;int&gt;?&nbsp;list&nbsp;=&nbsp;null;
list?&nbsp;=&nbsp;10;&nbsp;//&nbsp;不执行赋值

list&nbsp;=&nbsp;new&nbsp;List&lt;int&gt;&nbsp;{&nbsp;0&nbsp;};
list?&nbsp;=&nbsp;10;&nbsp;//&nbsp;执行赋值,list&nbsp;=&nbsp;10
Console.WriteLine(list);&nbsp;//&nbsp;10</code></pre>
<h4 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 16px; color: rgba(60, 112, 198, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 0 0 0 8px; border: 1px none rgba(0, 0, 0, 1)">适用场景</span></h4>
<ul style="list-style-type: disc; color: rgba(0, 0, 0, 1); padding: 0 0 0 25px; margin: 8px 0" data-tool="mdnice编辑器">
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">简化 null 检查,避免 NullReferenceException。</section>
</li>
</ul>
<h4 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: block; flex-direction: unset; float: unset; height: auto; justify-content: unset; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 16px; color: rgba(60, 112, 198, 1); line-height: 1.5em; letter-spacing: 0; align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: inline-block; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: unset; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 0 0 0 8px; border: 1px none rgba(0, 0, 0, 1)">注意事项</span></h4>
<ul style="list-style-type: disc; color: rgba(0, 0, 0, 1); padding: 0 0 0 25px; margin: 8px 0" data-tool="mdnice编辑器">
<li>
<section style="margin-top: 5px; margin-bottom: 5px; color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal">不支持 <code style="background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">++</code> 和 <code style="background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">--</code> 操作,详见空条件赋值。</section>
</li>
</ul>
<h2 style="align-items: unset; background: none left top / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); border-radius: 0; box-shadow: none; display: flex; flex-direction: unset; float: unset; height: auto; justify-content: center; line-height: 1.5em; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 0; margin: 30px 0 15px; border: 1px none rgba(0, 0, 0, 1)" data-tool="mdnice编辑器"><span class="content" style="font-size: 20px; color: rgba(255, 255, 255, 1); background: none left top / auto no-repeat scroll padding-box border-box rgba(130, 127, 196, 1); line-height: 1.5em; letter-spacing: 0; align-items: center; border-radius: 30px; box-shadow: none; display: flex; font-weight: bold; flex-direction: unset; float: unset; height: auto; justify-content: center; overflow-x: unset; overflow-y: unset; position: relative; text-align: left; text-indent: 0; text-shadow: none; transform: none; width: auto; -webkit-box-reflect: unset; padding: 10px; margin: 0; border: 1px none rgba(0, 0, 0, 1)">结语</span></h2>
<p style="color: rgba(63, 63, 63, 1); font-size: 16px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; text-indent: 0; padding: 16px 0 8px; margin: 0" data-tool="mdnice编辑器">C# 7.0至C# 14.0的类型系统新增内容涵盖了值元组、Span、ReadOnlySpan、Memory、ReadOnlyMemory、可空引用类型、记录、本机大小整数、记录结构、内联数组等数据类型,以及只读结构、引用结构、必需成员、泛型数学支持等增强。C# 14.0通过<code style="color: rgba(40, 202, 113, 1); font-size: 14px; line-height: 1.8em; letter-spacing: 0; background: none left top / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05); width: auto; height: auto; border-radius: 4px; overflow-wrap: break-word; font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace; word-break: break-all; border-top: 3px none rgba(0, 0, 0, 1); border-right: 3px none rgba(0, 0, 0, 0.4); border-bottom: 3px none rgba(0, 0, 0, 0.4); border-left: 3px none rgba(0, 0, 0, 0.4); padding: 2px 4px; margin: 0 2px">field</code>关键字、隐式 span 转换等特性进一步优化了现有类型的用法。这些特性满足了从高性能内存管理到类型安全建模的多种需求。资深C#工程师可根据场景选择类型,如使用Span优化性能,记录建模数据。由于C# 14.0尚在预览阶段,建议关注dotnet/roslyn以获取最新更新。</p>
</section>

</div>
<div id="MySignature" role="contentinfo">
    <p>
    本文来自博客园,作者:AI·NET极客圈,转载请注明原文链接:https://www.cnblogs.com/code-daily/p/18844112
</p>
<img src="https://images.cnblogs.com/cnblogs_com/blogs/272929/galleries/2447197/o_250311050355_AI.NET%20Logo.png" width="61.8%" style="margin-left:20px"/>

<p>
    欢迎关注我们的公众号,作为.NET工程师,我们聚焦人工智能技术,探讨 AI 的前沿应用与发展趋势,为你立体呈现人工智能的无限可能,让我们共同携手共同进步。
</p><br><br>
来源:https://www.cnblogs.com/code-daily/p/18844112
頁: [1]
查看完整版本: C#高性能开发之类型系统:从 C# 7.0 到 C# 14 的类型系统演进全景