mirror of
https://github.com/jaywcjlove/reference.git
synced 2025-06-18 05:01:21 +08:00
doc: docs/cs.md (#316) b1a10ee797
This commit is contained in:
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 3.6 MiB After Width: | Height: | Size: 3.7 MiB |
109
docs/cs.html
109
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="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">
|
||||
</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="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>
|
||||
@ -369,6 +369,113 @@
|
||||
</span><span class="code-line">Console<span class="token punctuation">.</span><span class="token function">WriteLine</span><span class="token punctuation">(</span>Rep<span class="token punctuation">)</span><span class="token punctuation">;</span>
|
||||
</span><span class="code-line"><span class="token comment">//会把字符中的 “1”替换成“串”</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">
|
||||
<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 class-name"><span class="token keyword">bool</span></span> A <span class="token operator">=</span> <span class="token boolean">true</span><span class="token punctuation">;</span>
|
||||
</span><span class="code-line"><span class="token class-name"><span class="token keyword">bool</span></span> B <span class="token operator">=</span> <span class="token boolean">false</span><span class="token punctuation">;</span>
|
||||
</span><span class="code-line"><span class="token class-name"><span class="token keyword">bool</span></span> Or <span class="token operator">=</span> A <span class="token operator">||</span> B<span class="token punctuation">;</span> <span class="token comment">// = A | B</span>
|
||||
</span><span class="code-line"><span class="token class-name"><span class="token keyword">bool</span></span> And <span class="token operator">=</span> A <span class="token operator">&&</span> B<span class="token punctuation">;</span> <span class="token comment">// = A & B</span>
|
||||
</span><span class="code-line"><span class="token class-name"><span class="token keyword">bool</span></span> Not <span class="token operator">=</span> <span class="token operator">!</span>A<span class="token punctuation">;</span>
|
||||
</span><span class="code-line"><span class="token comment">// ||,&& 与 |,& 分别为逻辑运算和条件逻辑运算, 两者的区别在于, 前者仅在必要时才会计算右侧的值, 后者始终计算右侧的值. 例如:</span>
|
||||
</span><span class="code-line"><span class="token class-name"><span class="token keyword">bool</span></span> C <span class="token operator">=</span> <span class="token boolean">false</span><span class="token punctuation">;</span>
|
||||
</span><span class="code-line"><span class="token class-name"><span class="token keyword">bool</span></span> D <span class="token operator">=</span> <span class="token boolean">true</span><span class="token punctuation">;</span>
|
||||
</span><span class="code-line"><span class="token return-type class-name"><span class="token keyword">bool</span></span> <span class="token function">CalcD</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
|
||||
</span><span class="code-line"> D <span class="token operator">=</span> <span class="token operator">!</span>D<span class="token punctuation">;</span>
|
||||
</span><span class="code-line"> <span class="token keyword">return</span> D<span class="token punctuation">;</span>
|
||||
</span><span class="code-line"><span class="token punctuation">}</span>
|
||||
</span><span class="code-line"><span class="token class-name"><span class="token keyword">bool</span></span> E <span class="token operator">=</span> C <span class="token operator">&&</span> <span class="token function">CalcD</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// C: false, D: false, E: false</span>
|
||||
</span><span class="code-line"><span class="token class-name"><span class="token keyword">bool</span></span> F <span class="token operator">=</span> C <span class="token operator">&</span> <span class="token function">CalcD</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// C:false, D: true, F: false</span>
|
||||
</span><span class="code-line"><span class="token comment">// 两种运算方法稍有不同, 计算结果始终相同, 但第二种可能造成其他影响.</span>
|
||||
</span><span class="code-line"><span class="token comment">//异或运算</span>
|
||||
</span><span class="code-line"><span class="token class-name"><span class="token keyword">bool</span></span> Xor <span class="token operator">=</span> A <span class="token operator">^</span> B<span class="token punctuation">;</span>
|
||||
</span></code></pre>
|
||||
<p>C#中的逻辑运算支持可空布尔类型运算. 注意条件逻辑运算不支持可空布尔类型.</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<table><thead><tr><th align="left">x</th><th>y</th><th>x&y</th><th>x|y</th><th>x^y</th><th>!x</th></tr></thead><tbody><tr><td align="left">true</td><td>true</td><td>true</td><td>true</td><td>false</td><td>false</td></tr><tr><td align="left">true</td><td>false</td><td>false</td><td>true</td><td>true</td><td>false</td></tr><tr><td align="left">true</td><td>null</td><td>null</td><td>true</td><td>null</td><td>false</td></tr><tr><td align="left">false</td><td>true</td><td>false</td><td>true</td><td>true</td><td>true</td></tr><tr><td align="left">false</td><td>false</td><td>false</td><td>false</td><td>false</td><td>true</td></tr><tr><td align="left">false</td><td>null</td><td>false</td><td>null</td><td>null</td><td>true</td></tr><tr><td align="left">null</td><td>true</td><td>null</td><td>true</td><td>null</td><td>null</td></tr><tr><td align="left">null</td><td>false</td><td>false</td><td>null</td><td>null</td><td>null</td></tr><tr><td align="left">null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td></tr></tbody></table>
|
||||
</div></div></div></div></div><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 col-span-3"><div class="wrap-header h3wrap"><h3 id="常用-net-概念"><a aria-hidden="true" tabindex="-1" href="#常用-net-概念"><span class="icon icon-link"></span></a>常用 .NET 概念</h3><div class="wrap-body">
|
||||
<!--rehype:wrap-class=col-span-3-->
|
||||
|
@ -781,6 +781,9 @@
|
||||
<a href="https://github.com/Country-If" title="Maylon">
|
||||
<img src="https://avatars.githubusercontent.com/u/62837275?v=4" width="42;" alt="Maylon">
|
||||
</a>
|
||||
<a href="https://github.com/qyl27" title="秋 雨落">
|
||||
<img src="https://avatars.githubusercontent.com/u/53731501?v=4" width="42;" alt="秋 雨落">
|
||||
</a>
|
||||
<a href="https://github.com/13812700839" title="花殇">
|
||||
<img src="https://avatars.githubusercontent.com/u/58072506?v=4" width="42;" alt="花殇">
|
||||
</a>
|
||||
@ -949,9 +952,6 @@
|
||||
<a href="https://github.com/LuckyJie12" title="夜未央">
|
||||
<img src="https://avatars.githubusercontent.com/u/102901105?v=4" width="42;" alt="夜未央">
|
||||
</a>
|
||||
<a href="https://github.com/qyl27" title="秋 雨落">
|
||||
<img src="https://avatars.githubusercontent.com/u/53731501?v=4" width="42;" alt="秋 雨落">
|
||||
</a>
|
||||
<a href="https://github.com/lisheng741" title="芦荟柚子茶">
|
||||
<img src="https://avatars.githubusercontent.com/u/53617305?v=4" width="42;" alt="芦荟柚子茶">
|
||||
</a><!--GAMFC-END-->
|
||||
@ -1091,7 +1091,7 @@
|
||||
<!--rehype:class=home-card home-links-->
|
||||
<p>如果你有资源,可以很方便<a href="https://github.com/jaywcjlove/reference/issues/102#issue-1451649637">部署 web 版</a>,这非常简单,只需要克隆 <a href="https://github.com/jaywcjlove/reference/tree/gh-pages">gh-pages</a> 分支代码到你的静态服务就可以了,还可以使用 <a href="https://hub.docker.com/r/wcjiang/reference">docker</a> 快捷部署 web 版。</p>
|
||||
|
||||
</div></div><div class="h2wrap-body"></div></div></div></div><footer class="footer-wrap"><footer class="max-container">© 2022 Kenny Wang. Updated on 2023/02/27 08:48:14</footer></footer><script src="data.js" defer></script><script src="js/fuse.min.js" defer></script><script src="js/main.js" defer></script><div id="mysearch"><div class="mysearch-box"><div class="mysearch-input"><div><svg xmlns="http://www.w3.org/2000/svg" height="1em" width="1em" viewBox="0 0 18 18">
|
||||
</div></div><div class="h2wrap-body"></div></div></div></div><footer class="footer-wrap"><footer class="max-container">© 2022 Kenny Wang. Updated on 2023/02/28 23:05:05</footer></footer><script src="data.js" defer></script><script src="js/fuse.min.js" defer></script><script src="js/main.js" defer></script><div id="mysearch"><div class="mysearch-box"><div class="mysearch-input"><div><svg xmlns="http://www.w3.org/2000/svg" height="1em" width="1em" viewBox="0 0 18 18">
|
||||
<path fill="currentColor" d="M17.71,16.29 L14.31,12.9 C15.4069846,11.5024547 16.0022094,9.77665502 16,8 C16,3.581722 12.418278,0 8,0 C3.581722,0 0,3.581722 0,8 C0,12.418278 3.581722,16 8,16 C9.77665502,16.0022094 11.5024547,15.4069846 12.9,14.31 L16.29,17.71 C16.4777666,17.8993127 16.7333625,18.0057983 17,18.0057983 C17.2666375,18.0057983 17.5222334,17.8993127 17.71,17.71 C17.8993127,17.5222334 18.0057983,17.2666375 18.0057983,17 C18.0057983,16.7333625 17.8993127,16.4777666 17.71,16.29 Z M2,8 C2,4.6862915 4.6862915,2 8,2 C11.3137085,2 14,4.6862915 14,8 C14,11.3137085 11.3137085,14 8,14 C4.6862915,14 2,11.3137085 2,8 Z"></path>
|
||||
</svg><input id="mysearch-input" type="search" placeholder="搜索" autocomplete="off"><div class="mysearch-clear"></div></div><button id="mysearch-close" type="button">搜索</button></div><div class="mysearch-result"><div id="mysearch-menu"></div><div id="mysearch-content"></div></div></div></div></body>
|
||||
</html>
|
||||
|
Reference in New Issue
Block a user