Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simultaneous update of Simplified Chinese documentation #1649

Merged
merged 3 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/Help_ZH-CN/Maps/table_of_contents.xml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@
<topicref type="topic" id="452217451269321" build="ALL" modified="2023-10-22T12:59:43.223Z" icon="0" href="__SeeAlsoExitLoop">
<caption translate="true">__SeeAlsoExitLoop</caption>
</topicref>
<topicref type="topic" id="456298376010241" build="ALL" modified="2024-12-03T23:56:26.887Z" icon="0" href="__InterpolatedStrings">
<caption translate="true">__InterpolatedStrings</caption>
</topicref>
</topicref>
<topicref type="topic" id="423886812341331" build="ALL" modified="2024-05-25T17:49:22.898Z" icon="0" href="XSharp">
<caption translate="true">X# 文档</caption>
Expand Down
13 changes: 3 additions & 10 deletions docs/Help_ZH-CN/Topics/StringLiterals.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="../helpproject.xsl" ?>
<topic template="Default" modified="2024-11-25T14:14:03.170+08:00" lasteditedby="niuji" version="2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../helpproject.xsd">
<topic template="Default" modified="2024-12-04T00:09:29.054+08:00" lasteditedby="niuji" version="2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../helpproject.xsd">
<title>String 字面量</title>
<keywords>
<keyword>Literals</keyword>
Expand Down Expand Up @@ -96,14 +96,7 @@
</table></para>
<para styleclass="Normal"></para>
<para styleclass="Normal"><snippet src="Escape-codes" inline="false"/></para>
<para styleclass="Normal"></para>
<para styleclass="" style="text-align:left; text-indent:0px; margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; line-height:1.00; background-color:transparent; white-space:normal; page-break-inside:auto; page-break-after:auto; border:none; tabstops:none;"><text styleclass="" style="font-family:Arial; font-size:10pt; color:#000000;">X# 内的插值字符串可以包含以下形式的表达式</text></para>
<para styleclass="Code Example"><text style="font-weight:normal; font-style:normal; text-decoration:none; color:#3366ff;">{&lt;interpolationExpression&gt;[,&lt;alignment&gt;][::&lt;formatString&gt;]}</text></para>
<para styleclass="Body Text">在 C# 中,formatString 的前缀是单冒号。请注意,由于在 X# 中,冒号(:)操作符是实例字段、属性和方法的默认成员访问操作符,因此并不总是可以使用该操作符来分隔表达式和格式字符串。因此,我们将该操作符改为双冒号(::)。如果使用 /allowdot+ 进行编译,也可以使用单冒号作为格式分隔符。</para>
<para styleclass="Body Text">要表示字面上的“{”或“}”字符,必须在字符串中复制它们。本例中字符串内的表达式用斜体表示。</para>
<para styleclass="Body Text"></para>
<para styleclass="Body Text">例如</para>
<para styleclass="Code Example"><text style="font-weight:normal; font-style:normal; text-decoration:none; color:#000000;"> &#160;</text><text style="font-weight:bold; font-style:normal; text-decoration:none; color:#ff0000;">FUNCTION</text><text style="font-weight:normal; font-style:normal; text-decoration:none; color:#000000;"> Start() </text><text style="font-weight:bold; font-style:normal; text-decoration:none; color:#ff0000;">AS</text><text style="font-weight:normal; font-style:normal; text-decoration:none; color:#000000;">&#32;</text><text style="font-weight:bold; font-style:normal; text-decoration:none; color:#ff0000;">VOID</text><br/><text style="font-weight:normal; font-style:normal; text-decoration:none; color:#000000;"> &#160; </text><text style="font-weight:bold; font-style:normal; text-decoration:none; color:#ff0000;">local</text><text style="font-weight:normal; font-style:normal; text-decoration:none; color:#000000;"> X := 2 </text><text style="font-weight:bold; font-style:normal; text-decoration:none; color:#ff0000;">as</text><text style="font-weight:normal; font-style:normal; text-decoration:none; color:#000000;">&#32;</text><text style="font-weight:bold; font-style:normal; text-decoration:none; color:#ff0000;">INT</text><br/><text style="font-weight:normal; font-style:normal; text-decoration:none; color:#000000;"> &#160; </text><text style="font-weight:bold; font-style:normal; text-decoration:none; color:#ff0000;">local</text><text style="font-weight:normal; font-style:normal; text-decoration:none; color:#000000;"> Y := 3 </text><text style="font-weight:bold; font-style:normal; text-decoration:none; color:#ff0000;">as</text><text style="font-weight:normal; font-style:normal; text-decoration:none; color:#000000;">&#32;</text><text style="font-weight:bold; font-style:normal; text-decoration:none; color:#ff0000;">INT</text><br/><text style="font-weight:normal; font-style:normal; text-decoration:none; color:#000000;"> &#160; </text><text style="font-weight:bold; font-style:normal; text-decoration:none; color:#ff0000;">var</text><text style="font-weight:normal; font-style:normal; text-decoration:none; color:#000000;"> pointMessage := i</text><text style="font-weight:normal; font-style:normal; text-decoration:none; color:#3366ff;">&quot;The point {{{</text><text style="font-weight:bold; font-style:italic; text-decoration:none; color:#3366ff;">X</text><text style="font-weight:normal; font-style:normal; text-decoration:none; color:#3366ff;">}, {</text><text style="font-weight:bold; font-style:italic; text-decoration:none; color:#3366ff;">Y</text><text style="font-weight:normal; font-style:normal; text-decoration:none; color:#3366ff;">}}} is {</text><text style="font-weight:bold; font-style:italic; text-decoration:none; color:#3366ff;">Math.Sqrt(X * X + Y * Y)</text><text style="font-weight:normal; font-style:normal; text-decoration:none; color:#3366ff;">::F3} from the origin&quot;</text><br/><text style="font-weight:normal; font-style:normal; text-decoration:none; color:#000000;"> &#160; </text><text style="font-weight:bold; font-style:normal; text-decoration:none; color:#ff0000;">Console</text><text style="font-weight:normal; font-style:normal; text-decoration:none; color:#000000;">.WriteLine(pointMessage)</text><br/><tab /><text style="font-style:italic; text-decoration:none; color:#339966;">// 输出结果:</text><br/><tab /><text style="font-style:italic; text-decoration:none; color:#339966;">// The point {2, 3} is 3.606 from the origin</text></para>
<para styleclass="Code Example"></para>
<para styleclass="" style="text-align:left; text-indent:0px; margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; line-height:1.00; background-color:transparent; white-space:normal; page-break-inside:auto; page-break-after:auto; border:none; tabstops:none;"></para>
<para styleclass="Normal"><snippet src="__InterpolatedStrings" inline="false"/></para>
</body>
</topic>
32 changes: 32 additions & 0 deletions docs/Help_ZH-CN/Topics/__InterpolatedStrings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="../helpproject.xsl" ?>
<topic template="Default" modified="2024-12-04T00:07:55.077+08:00" lasteditedby="niuji" version="2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../helpproject.xsd">
<title>__InterpolatedStrings</title>
<body>
<header>
<para styleclass="Heading1">__InterpolatedStrings</para>
</header>
<para styleclass="Normal">插值字符串是一种允许将局部变量、实例变量或其他表达式嵌入字面字符串的功能。X# 支持两种插值字符串:</para>
<para styleclass="Normal"></para>
<para styleclass="Heading2"><text style="font-weight:bold;">1.</text><tab /><text style="font-weight:bold;">常规插值字符串: i&quot;....&quot;</text></para>
<para styleclass="Normal"><tab /></para>
<para styleclass="Normal">其工作方式与普通 X# 字符串类似,内嵌表达式:</para>
<para styleclass="Normal"></para>
<para styleclass="Code Example"><tab /><text style="font-weight:bold; font-style:normal; color:#3366ff;">FUNCTION</text><text style="font-weight:normal; font-style:normal; color:#000000;"> Start </text><text style="font-weight:bold; font-style:normal; color:#3366ff;">AS</text><text style="font-weight:normal; font-style:normal; color:#000000;">&#32;</text><text style="font-weight:bold; font-style:normal; color:#3366ff;">VOID</text><br/><text style="font-weight:normal; font-style:normal; color:#000000;"> &#160; &#160; &#160;</text><text style="font-weight:bold; font-style:normal; color:#3366ff;">LOCAL</text><text style="font-weight:normal; font-style:normal; color:#000000;"> Who </text><text style="font-weight:bold; font-style:normal; color:#3366ff;">AS</text><text style="font-weight:normal; font-style:normal; color:#000000;">&#32;</text><text style="font-weight:bold; font-style:normal; color:#3366ff;">STRING</text><br/><text style="font-weight:normal; font-style:normal; color:#000000;"> &#160; &#160; &#160;Who := </text><text style="font-weight:bold; font-style:normal; color:#993366;">&quot;World&quot;</text><br/><text style="font-weight:normal; font-style:normal; color:#000000;"> &#160; &#160; &#160;Console.Writeline( i</text><text style="font-weight:bold; font-style:normal; color:#993366;">&quot;Hello {Who}&quot;</text><text style="font-weight:normal; font-style:normal; color:#000000;">)</text><br/><text style="font-weight:normal; font-style:normal; color:#000000;"> &#160; &#160; &#160;Console.Read()</text><br/><text style="font-weight:normal; font-style:normal; color:#000000;"> &#160; &#160; &#160;</text><text style="font-weight:bold; font-style:normal; color:#3366ff;">RETURN</text></para>
<para styleclass="Heading2">2.<tab />扩展插值字符串: ie&quot;...&quot; 和 ei&quot;....&quot;</para>
<para styleclass="Normal">这是插值字符串和扩展字符串的组合。在下面的示例中,\t 将被 tab 字符替换:</para>
<para styleclass="Normal"></para>
<para styleclass="Code Example"><text style="font-weight:normal; font-style:normal; color:#000000;"> &#160; </text><text style="font-weight:bold; font-style:normal; color:#3366ff;">FUNCTION</text><text style="font-weight:normal; font-style:normal; color:#000000;"> Start </text><text style="font-weight:bold; font-style:normal; color:#3366ff;">AS</text><text style="font-weight:normal; font-style:normal; color:#000000;">&#32;</text><text style="font-weight:bold; font-style:normal; color:#3366ff;">VOID</text><br/><text style="font-weight:normal; font-style:normal; color:#000000;"> &#160; &#160; &#160;</text><text style="font-weight:bold; font-style:normal; color:#3366ff;">LOCAL</text><text style="font-weight:normal; font-style:normal; color:#000000;"> Who </text><text style="font-weight:bold; font-style:normal; color:#3366ff;">AS</text><text style="font-weight:normal; font-style:normal; color:#000000;">&#32;</text><text style="font-weight:bold; font-style:normal; color:#3366ff;">STRING</text><br/><text style="font-weight:normal; font-style:normal; color:#000000;"> &#160; &#160; &#160;Who := </text><text style="font-weight:bold; font-style:normal; color:#993366;">&quot;World&quot;</text><br/><text style="font-weight:normal; font-style:normal; color:#000000;"> &#160; &#160; &#160;Console.Writeline( ie</text><text style="font-weight:bold; font-style:normal; color:#993366;">&quot;Hello\t{Who}&quot;</text><text style="font-weight:normal; font-style:normal; color:#000000;">)</text><br/><text style="font-weight:normal; font-style:normal; color:#000000;"> &#160; &#160; &#160;Console.Read()</text><br/><text style="font-weight:normal; font-style:normal; color:#000000;"> &#160; &#160; &#160;</text><text style="font-weight:bold; font-style:normal; color:#3366ff;">RETURN</text></para>
<para styleclass="Heading2">注意:</para>
<para styleclass="" style="text-align:left; text-indent:0px; margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; line-height:1.00; background-color:transparent; white-space:normal; page-break-inside:auto; page-break-after:auto; border:none; tabstops:none;"><text styleclass="" style="font-family:Arial; font-size:10pt; color:#000000;">X# 内的插值字符串可以包含以下形式的表达式</text></para>
<para styleclass="Code Example"><text style="font-weight:normal; font-style:normal; text-decoration:none; color:#3366ff;">{&lt;interpolationExpression&gt;[,&lt;alignment&gt;][::&lt;formatString&gt;]}</text></para>
<para styleclass="Body Text">在 C# 中,formatString 的前缀是单冒号。请注意,由于在 X# 中,冒号(:)操作符是实例字段、属性和方法的默认成员访问操作符,因此并不总是可以使用该操作符来分隔表达式和格式字符串。因此,我们将该操作符改为双冒号(::)。如果使用 /allowdot+ 进行编译,也可以使用单冒号作为格式分隔符。</para>
<para styleclass="Body Text"></para>
<para styleclass="Body Text">要表示字面上的“{”或“}”字符,必须在字符串中复制它们。本例中字符串内的表达式用斜体表示。</para>
<para styleclass="Code Example"><text style="font-weight:normal; font-style:normal; text-decoration:none; color:#000000;"> &#160;</text><text style="font-weight:bold; font-style:normal; text-decoration:none; color:#ff0000;">FUNCTION</text><text style="font-weight:normal; font-style:normal; text-decoration:none; color:#000000;"> Start() </text><text style="font-weight:bold; font-style:normal; text-decoration:none; color:#ff0000;">AS</text><text style="font-weight:normal; font-style:normal; text-decoration:none; color:#000000;">&#32;</text><text style="font-weight:bold; font-style:normal; text-decoration:none; color:#ff0000;">VOID</text><br/><text style="font-weight:normal; font-style:normal; text-decoration:none; color:#000000;"> &#160; </text><text style="font-weight:bold; font-style:normal; text-decoration:none; color:#ff0000;">local</text><text style="font-weight:normal; font-style:normal; text-decoration:none; color:#000000;"> X := 2 </text><text style="font-weight:bold; font-style:normal; text-decoration:none; color:#ff0000;">as</text><text style="font-weight:normal; font-style:normal; text-decoration:none; color:#000000;">&#32;</text><text style="font-weight:bold; font-style:normal; text-decoration:none; color:#ff0000;">INT</text><br/><text style="font-weight:normal; font-style:normal; text-decoration:none; color:#000000;"> &#160; </text><text style="font-weight:bold; font-style:normal; text-decoration:none; color:#ff0000;">local</text><text style="font-weight:normal; font-style:normal; text-decoration:none; color:#000000;"> Y := 3 </text><text style="font-weight:bold; font-style:normal; text-decoration:none; color:#ff0000;">as</text><text style="font-weight:normal; font-style:normal; text-decoration:none; color:#000000;">&#32;</text><text style="font-weight:bold; font-style:normal; text-decoration:none; color:#ff0000;">INT</text><br/><text style="font-weight:normal; font-style:normal; text-decoration:none; color:#000000;"> &#160; </text><text style="font-weight:bold; font-style:normal; text-decoration:none; color:#ff0000;">var</text><text style="font-weight:normal; font-style:normal; text-decoration:none; color:#000000;"> pointMessage := i</text><text style="font-weight:normal; font-style:normal; text-decoration:none; color:#3366ff;">&quot;The point {{{</text><text style="font-weight:bold; font-style:italic; text-decoration:none; color:#3366ff;">X</text><text style="font-weight:normal; font-style:normal; text-decoration:none; color:#3366ff;">}, {</text><text style="font-weight:bold; font-style:italic; text-decoration:none; color:#3366ff;">Y</text><text style="font-weight:normal; font-style:normal; text-decoration:none; color:#3366ff;">}}} is {</text><text style="font-weight:bold; font-style:italic; text-decoration:none; color:#3366ff;">Math.Sqrt(X * X + Y * Y)</text><text style="font-weight:normal; font-style:normal; text-decoration:none; color:#3366ff;">::F3} from the origin&quot;</text><br/><text style="font-weight:normal; font-style:normal; text-decoration:none; color:#000000;"> &#160; </text><text style="font-weight:bold; font-style:normal; text-decoration:none; color:#ff0000;">Console</text><text style="font-weight:normal; font-style:normal; text-decoration:none; color:#000000;">.WriteLine(pointMessage)</text><br/><tab /><text style="font-style:italic; text-decoration:none; color:#339966;">// 输出结果:</text><br/><tab /><text style="font-style:italic; text-decoration:none; color:#339966;">// The point {2, 3} is 3.606 from the origin</text></para>
<para styleclass="Body Text"></para>
<para styleclass="Normal">字符串内的表达式元素可以使用格式化符号,就像 String.Format() 符号一样。例如:</para>
<para styleclass="Normal"></para>
<para styleclass="Code Example"><tab /><text style="font-weight:bold; font-style:normal; color:#3366ff;">FUNCTION</text><text style="font-weight:normal; font-style:normal; color:#000000;"> Start </text><text style="font-weight:bold; font-style:normal; color:#3366ff;">AS</text><text style="font-weight:normal; font-style:normal; color:#000000;">&#32;</text><text style="font-weight:bold; font-style:normal; color:#3366ff;">VOID</text><br/><text style="font-weight:normal; font-style:normal; color:#000000;"> &#160; &#160; &#160;</text><text style="font-weight:bold; font-style:normal; color:#3366ff;">LOCAL</text><text style="font-weight:normal; font-style:normal; color:#000000;"> i </text><text style="font-weight:bold; font-style:normal; color:#3366ff;">AS</text><text style="font-weight:normal; font-style:normal; color:#000000;"> INT</text><br/><text style="font-weight:normal; font-style:normal; color:#000000;"> &#160; &#160; &#160;i := 42</text><br/><text style="font-weight:normal; font-style:normal; color:#000000;"> &#160; &#160; &#160;Console.Writeline( i</text><text style="font-weight:bold; font-style:normal; color:#993366;">&quot;Hello {i:x}&quot;</text><text style="font-weight:normal; font-style:normal; color:#000000;">) &#160; </text><text style="font-weight:normal; font-style:italic; color:#339966;">// i 用十六进制表示,所以输出 Hello 2a</text><br/><text style="font-weight:normal; font-style:normal; color:#000000;"> &#160; &#160; &#160;Console.Read()</text><br/><text style="font-weight:normal; font-style:normal; color:#000000;"> &#160; &#160; </text><text style="font-weight:bold; font-style:normal; color:#3366ff;">RETURN</text></para>
</body>
</topic>
Loading