mirror of
https://github.com/jaywcjlove/reference.git
synced 2025-06-19 13:41:21 +08:00
doc: update docs/cs.md (#584) ea8d6b3391
This commit is contained in:
58
docs/cs.html
58
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="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="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="#逻辑运算">逻辑运算</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">
|
||||
</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="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="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="#逻辑运算">逻辑运算</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="#默认情况默认情况即为内部类">默认情况(默认情况即为内部类)</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>
|
||||
@ -826,6 +826,62 @@
|
||||
</span><span class="code-line"><span class="token comment">// 计算第二个操作数</span>
|
||||
</span><span class="code-line"><span class="token comment">// True</span>
|
||||
</span></code></pre>
|
||||
</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"><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><code class="code-highlight"><span class="code-line">//下面两个类相同,默认情况下,类声明为内部类,即只能在当前项目中的代码才能访问它
|
||||
</span><span class="code-line">class MyClass
|
||||
</span><span class="code-line">{
|
||||
</span><span class="code-line">...
|
||||
</span><span class="code-line">}
|
||||
</span><span class="code-line">internal class MyCalss
|
||||
</span><span class="code-line">{
|
||||
</span><span class="code-line">...
|
||||
</span><span class="code-line">}
|
||||
</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><code class="code-highlight"><span class="code-line">public class MyClass
|
||||
</span><span class="code-line">{
|
||||
</span><span class="code-line">...
|
||||
</span><span class="code-line">}
|
||||
</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><code class="code-highlight"><span class="code-line">//抽象类(abstract)与密封类(sealed)为互斥关系,抽象类不能实例化,允许继承,可以有抽象成员,密封类不允许继承
|
||||
</span><span class="code-line">//抽象类与密封类都可以声明为公共类(public)和内部类(internal)
|
||||
</span><span class="code-line">public abstract class MyClass
|
||||
</span><span class="code-line">{
|
||||
</span><span class="code-line">...
|
||||
</span><span class="code-line">}
|
||||
</span><span class="code-line">public sealed class MyClass
|
||||
</span><span class="code-line">{
|
||||
</span><span class="code-line">...
|
||||
</span><span class="code-line">}
|
||||
</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><code class="code-highlight"><span class="code-line">/*
|
||||
</span><span class="code-line">注意,在C#的类定义中,只能有一个基类。如果继承了一个抽象类,就必须实现所继承的所有抽象成员(除非派生类也是抽象的)。
|
||||
</span><span class="code-line">编译器不允许派生类的可访问性高于基类。也就是说,内部类可以继承于一个公共基类,但公共类不能继承于一个内部基类。因此,下述代码是合法的:
|
||||
</span><span class="code-line">*/
|
||||
</span><span class="code-line">public class MyBase
|
||||
</span><span class="code-line">{
|
||||
</span><span class="code-line"> // Class members.
|
||||
</span><span class="code-line">}
|
||||
</span><span class="code-line">internal class MyClass : MyBase
|
||||
</span><span class="code-line">{
|
||||
</span><span class="code-line"> // Class members.
|
||||
</span><span class="code-line">}
|
||||
</span><span class="code-line">//但下述代码不能编译:
|
||||
</span><span class="code-line">internal class MyBase
|
||||
</span><span class="code-line">{
|
||||
</span><span class="code-line"> // Class members.
|
||||
</span><span class="code-line">}
|
||||
</span><span class="code-line">public class MyClass : MyBase
|
||||
</span><span class="code-line">{
|
||||
</span><span class="code-line"> // Class members.
|
||||
</span><span class="code-line">}
|
||||
</span><span class="code-line">/*
|
||||
</span><span class="code-line">如果没有使用基类,被定义的类就只继承于基类 System.Object(它在 C#中的别名是 object)。毕竟,在继承层次结构中,所有类的根都是 System.Object。
|
||||
</span><span class="code-line">*/
|
||||
</span></code></pre>
|
||||
</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-->
|
||||
|
Reference in New Issue
Block a user