mirror of
https://github.com/jaywcjlove/reference.git
synced 2025-06-22 06:51:31 +08:00
doc(cs): update cs.md. (#314) 88d42e6ac8
This commit is contained in:
202
docs/cs.html
202
docs/cs.html
@ -31,7 +31,7 @@
|
||||
<p>提供基本语法和方法的 C# 快速参考备忘单</p>
|
||||
</div></header><div class="menu-tocs"><div class="menu-btn"><svg aria-hidden="true" fill="currentColor" height="1em" width="1em" viewBox="0 0 16 16" version="1.1" data-view-component="true">
|
||||
<path fill-rule="evenodd" d="M2 4a1 1 0 100-2 1 1 0 000 2zm3.75-1.5a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5zm0 5a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5zm0 5a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5zM3 8a1 1 0 11-2 0 1 1 0 012 0zm-1 6a1 1 0 100-2 1 1 0 000 2z"></path>
|
||||
</svg></div><div class="menu-modal"><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#入门">入门</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#hellocs">Hello.cs</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#变量">变量</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#原始数据类型">原始数据类型</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#注释">注释</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#字符串">字符串</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#用户输入">用户输入</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#条件判断">条件判断</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#数组">数组</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#循环">循环</a><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#c-字符串">C# 字符串</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#字符串连接">字符串连接</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#字符串插值">字符串插值</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#字符串成员">字符串成员</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#逐字字符串">逐字字符串</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#成员示例">成员示例</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#频繁字符串拼接">频繁字符串拼接</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#原始字符串文本">原始字符串文本</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#字符串操作">字符串操作</a><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#杂项">杂项</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#常用-net-概念">常用 .NET 概念</a></div></div><div class="h1wrap-body"><div class="wrap h2body-exist"><div class="wrap-header h2wrap"><h2 id="入门"><a aria-hidden="true" tabindex="-1" href="#入门"><span class="icon icon-link"></span></a>入门</h2><div class="wrap-body">
|
||||
</svg></div><div class="menu-modal"><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#入门">入门</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#hellocs">Hello.cs</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#变量">变量</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#注释">注释</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#字符串">字符串</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#用户输入">用户输入</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#条件判断">条件判断</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#数组">数组</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#循环">循环</a><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#c-数据类型">C# 数据类型</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#原始数据类型">原始数据类型</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#基本数据类型">基本数据类型</a><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#c-字符串">C# 字符串</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#字符串连接">字符串连接</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#字符串插值">字符串插值</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#字符串成员">字符串成员</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#逐字字符串">逐字字符串</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#成员示例">成员示例</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#频繁字符串拼接">频繁字符串拼接</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#原始字符串文本">原始字符串文本</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#字符串操作">字符串操作</a><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#杂项">杂项</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#常用-net-概念">常用 .NET 概念</a></div></div><div class="h1wrap-body"><div class="wrap h2body-exist"><div class="wrap-header h2wrap"><h2 id="入门"><a aria-hidden="true" tabindex="-1" href="#入门"><span class="icon icon-link"></span></a>入门</h2><div class="wrap-body">
|
||||
</div></div><div class="h2wrap-body"><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="hellocs"><a aria-hidden="true" tabindex="-1" href="#hellocs"><span class="icon icon-link"></span></a>Hello.cs</h3><div class="wrap-body">
|
||||
<pre class="language-cs"><code class="language-cs code-highlight"><span class="code-line"><span class="token keyword">class</span> <span class="token class-name">Hello</span> <span class="token punctuation">{</span>
|
||||
</span><span class="code-line"> <span class="token comment">// main method</span>
|
||||
@ -59,59 +59,6 @@
|
||||
</span><span class="code-line"><span class="token class-name"><span class="token keyword">var</span></span> str <span class="token operator">=</span> <span class="token string">"999"</span><span class="token punctuation">;</span>
|
||||
</span><span class="code-line"><span class="token class-name"><span class="token keyword">var</span></span> bo <span class="token operator">=</span> <span class="token boolean">false</span><span class="token punctuation">;</span>
|
||||
</span></code></pre>
|
||||
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="原始数据类型"><a aria-hidden="true" tabindex="-1" href="#原始数据类型"><span class="icon icon-link"></span></a>原始数据类型</h3><div class="wrap-body">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<table class="show-header"><thead><tr><th align="left">数据类型</th><th>尺寸</th><th>范围</th></tr></thead><tbody><tr><td align="left"><code>int</code></td><td>4 bytes</td><td>-2^31^ ^to^ 2^31^-1</td></tr><tr><td align="left"><code>long</code></td><td>8 bytes</td><td>-2^63^ ^to^ 2^63^-1</td></tr><tr><td align="left"><code>float</code></td><td>4 bytes</td><td>6 ^to^ 7 decimal digits</td></tr><tr><td align="left"><code>double</code></td><td>8 bytes</td><td>15 decimal digits</td></tr><tr><td align="left"><code>decimal</code></td><td>16 bytes</td><td>28 ^to^ 29 decimal digits</td></tr><tr><td align="left"><code>char</code></td><td>2 bytes</td><td>0 ^to^ 65535</td></tr><tr><td align="left"><code>bool</code></td><td>1 bit</td><td>true / false</td></tr><tr><td align="left"><code>string</code></td><td>2 bytes per char</td><td><em>N/A</em></td></tr></tbody></table>
|
||||
<!--rehype:className=show-header-->
|
||||
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="注释"><a aria-hidden="true" tabindex="-1" href="#注释"><span class="icon icon-link"></span></a>注释</h3><div class="wrap-body">
|
||||
<pre class="language-cs"><code class="language-cs code-highlight"><span class="code-line"><span class="token comment">// 单行注释</span>
|
||||
</span><span class="code-line"><span class="token comment">/* 多行
|
||||
@ -166,6 +113,153 @@
|
||||
</span><span class="code-line"> Console<span class="token punctuation">.</span><span class="token function">WriteLine</span><span class="token punctuation">(</span>num<span class="token punctuation">)</span><span class="token punctuation">;</span>
|
||||
</span><span class="code-line"><span class="token punctuation">}</span>
|
||||
</span></code></pre>
|
||||
</div></div></div></div></div><div class="wrap h2body-exist"><div class="wrap-header h2wrap"><h2 id="c-数据类型"><a aria-hidden="true" tabindex="-1" href="#c-数据类型"><span class="icon icon-link"></span></a>C# 数据类型</h2><div class="wrap-body">
|
||||
</div></div><div class="h2wrap-body"><div class="wrap h3body-not-exist col-span-2"><div class="wrap-header h3wrap"><h3 id="原始数据类型"><a aria-hidden="true" tabindex="-1" href="#原始数据类型"><span class="icon icon-link"></span></a>原始数据类型</h3><div class="wrap-body">
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<table class="show-header"><thead><tr><th>关键字</th><th>名称</th><th>System 别名</th><th>占用空间</th><th>数据范围</th></tr></thead><tbody><tr><td>bool</td><td>布尔型</td><td>Boolean</td><td>1</td><td>true/false</td></tr><tr><td>sbyte</td><td>有符号字节型</td><td>SByte</td><td>1</td><td>-128 ~ 127</td></tr><tr><td>byte</td><td>字节型</td><td>Byte</td><td>1</td><td>0 ~ 255</td></tr><tr><td>short</td><td>短整型</td><td>Int16</td><td>2</td><td>-32,768 ~ 32,767</td></tr><tr><td>ushort</td><td>无符号短整型</td><td>UInt16</td><td>2</td><td>0 ~ 65,535</td></tr><tr><td>int</td><td>整型</td><td>Int32</td><td>4</td><td>-2,147,483,648 ~ 2,147,483,647</td></tr><tr><td>uint</td><td>无符号整型</td><td>UInt32</td><td>4</td><td>0 ~ 4,294,967,295</td></tr><tr><td>long</td><td>长整型</td><td>Int64</td><td>8</td><td>-2^63 ~ 2^63-1</td></tr><tr><td>ulong</td><td>无符号长整型</td><td>UInt64</td><td>8</td><td>0 ~ 2^64-1</td></tr><tr><td>char</td><td>字符型</td><td>Char</td><td>8</td><td>UTF-16 所编码的字符</td></tr><tr><td>float</td><td>单精度浮点型</td><td>Single</td><td>4</td><td>±1.5x10^45 ~ ±3.4x10^38</td></tr><tr><td>double</td><td>双精度浮点型</td><td>Double</td><td>8</td><td>±5.0x10^-324 ~ ±1.7x10^308</td></tr><tr><td>N/A</td><td>指针型</td><td>IntPtr</td><td>与指针相同</td><td>与指针相同(受操作系统和处理器位宽影响)</td></tr><tr><td>N/A</td><td>无符号指针型</td><td>UIntPtr</td><td>与指针相同</td><td>与指针相同(受操作系统和处理器位宽影响)</td></tr></tbody></table>
|
||||
<!--rehype:className=show-header-->
|
||||
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="基本数据类型"><a aria-hidden="true" tabindex="-1" href="#基本数据类型"><span class="icon icon-link"></span></a>基本数据类型</h3><div class="wrap-body">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<table class="show-header"><thead><tr><th>关键字</th><th>名称</th><th>System 别名</th><th>说明</th></tr></thead><tbody><tr><td>(除指针型外的全部原始数据类型)</td><td></td><td></td><td>原始数据类型都是值类型,基本数据类型包含部分本质上是引用的数据类型</td></tr><tr><td>string</td><td>字符串</td><td>String</td><td>可变长度</td></tr><tr><td>decimal</td><td>十进制浮点数</td><td>Decimal</td><td>适合处理货币等计算,16字节长,不遵循 IEEE 754 关于浮点数的规则</td></tr></tbody></table>
|
||||
<!--rehype:className=show-header-->
|
||||
</div></div></div></div></div><div class="wrap h2body-exist"><div class="wrap-header h2wrap"><h2 id="c-字符串"><a aria-hidden="true" tabindex="-1" href="#c-字符串"><span class="icon icon-link"></span></a>C# 字符串</h2><div class="wrap-body">
|
||||
</div></div><div class="h2wrap-body"><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="字符串连接"><a aria-hidden="true" tabindex="-1" href="#字符串连接"><span class="icon icon-link"></span></a>字符串连接</h3><div class="wrap-body">
|
||||
<pre class="language-cs"><code class="language-cs code-highlight"><span class="code-line"><span class="token class-name"><span class="token keyword">string</span></span> first <span class="token operator">=</span> <span class="token string">"John"</span><span class="token punctuation">;</span>
|
||||
|
Reference in New Issue
Block a user