C#
![本頁使用了標題或全文手工轉換](https://upload.wikimedia.org/wikipedia/commons/thumb/c/cd/Zh_conversion_icon_m.svg/35px-Zh_conversion_icon_m.svg.png)
![]() | |
C | |
2000 | |
| |
Windows、Linux、Mac OS X 、 Android | |
| |
.cs , .csx | |
docs | |
.NET、.NET | |
衍生 | |
C | |
C++、Java、Eiffel、Modula-3、Object Pascal | |
Clojure[4]、D |
C#
命名
[C#
設計 目標
[ECMA
- C#
旨 在 設計 成 為 一 種 「簡單 、現代 、通用 」,以及物件 導 向 的 程 式 設計 語 言 - 此種
語 言 的 實現 ,應 提供 對 於以下 軟體工程 要素 的 支援 :強 型 別 檢 查、陣列 維度檢 查、未 初 始 化 的 變數 參照 檢 測 、自動 垃圾收集 (Garbage Collection,指 一種記憶體自動釋放技術)。軟體必須 做到強大 、持久 ,並 具有 較強程 式 開發 的 生產 力 。 - 此種
語 言 為 在 分散 式 環境 中 的 開發 提供 適用 的 組 件 開發 應用 。 為 使 程 式 設計 師 容易 遷移 到 這種語 言 ,原始 碼的可 移植 性 十 分 重要 ,尤 其是對 於那些已熟 悉C和 C++的 程 式 設計 師 而言。對 國際 化 的 支援 非常 重要 。- C#
適合 為 獨立 和 嵌入 式 的 系統 編 寫 程 式 ,從 使用 複雜 作業 系統 的 大型 系統 到 特定 應用 的 小型 系統 均 適用 。
歷史
[版本
[語 言 特性
[指標 (Pointer)只 能 用 於不安全 模 式 之 中 。大 多數 對象 訪問 透過 安全 的 參照 實現 ,以避免 無效 的 調 用 ,並 且有許多 演算 法 用 於檢查溢位 ,指標 只 能 用 於調用 值類型 ,以及受垃圾收集 控 制 的 代 管 對象 。對象 不能 被 顯 式 釋放 ,代替 為當 不 存在 被參照 時 透過 垃圾回收 器 回收 。只 允許 單一 繼承 (single inheritance),但 是 一個類可以實現多個介 面 (interfaces)。- C#
比 C++更 加 類型 安全 。預 設 的 安全 轉換 是 隱 含轉換 ,例 如由短 整 型 轉換 為 長 整 型 和 從 衍生類 轉換 為 基本 類 。而介面 布 林 數 同 整 型 ,及枚舉型同 整 型 不 允許 隱 含轉換 ,非 空 指標 (透過 參照 相似 對象 )同 使用 者 定義 類型 的 隱 含轉換 欄 位 被 顯 式 的 確定 ,不同 於C++的 複製 構造 函 式 。 陣列 宣告 的 語法 不同 ("int[] a = new int[5]"而不是 "int a[5]")。枚 舉位 於其所在 的 命名 空間 中 。- C#
中 沒 有 模 版 (Template),但 是 在 C# 2.0中 引入了 泛型(Generic programming),並 且支援 一 些C++模 版 不 支援 的 特性 。比 如泛型 參 數 中 的 類型 約束 。另一方面 ,表 達 式 不能 像 C++模 版 中 被 用 於類型 參 數 。 屬性 支援 ,使用 類似 訪問 成員 的 方式 調 用 。完 整 的 反射 支援 。
C# 2.0的 特性
[部分 類
[file1.cs:
public partial class MyClass1
{
public void MyMethod1()
{
// implementation
}
}
file2.cs:
public partial class MyClass1
{
public void MyMethod2()
{
// implementation
}
}
泛型
[泛型,
它
泛型
class Node<T, V>
where T : Stack, IComparable, new(), class
where V : Stack, struct
{...}
泛型
泛型
泛型
靜態 類別
[迭代器
[yield return
yield
// Method that takes an iterable input (possibly an array)
// and returns all even numbers.
public static IEnumerable<int> GetEven(IEnumerable<int> numbers)
{
foreach (int i in numbers)
{
if (i % 2 == 0) yield return i;
}
}
- foreach迴圈
時 考慮 執行 緒 安全 性 ,不要 試 圖 對 被 遍歷 的 集合 進行 remove和 add等 操作 - IEnumerable
介 面 是 LINQ特性 的 核心 介 面 。只 有 實現 了 IEnumerable介 面 的 集合 ,才能 執行 相關 的 LINQ操作 ,比 如select,where等
匿名 方法
[delegate void NumberChanger(int n);
NumberChanger nc = delegate(int x)
{
Console.WriteLine("Anonymous Method: {0}", x);
};
public void Foo(object parameter)
{
// ...
ThreadPool.QueueUserWorkItem(delegate
{
// anonymous delegates have full access to local variables of the enclosing method
if(parameter == ...)
{
// ...
}
// ...
});
}
委託 的 協 變 和 逆 變
[屬性 訪問 器 可 以被單獨 設定 訪問 級 別
[string status = string.Empty;
public string Status
{
get { return status; } // anyone can get value of this property,
protected set { status = value; } // but only derived classes can change it
}
可 空 類型
[int? i = null;
)null
int? i = null;
object o = i;
if(o == null)
Console.WriteLine("Correct behaviour - runtime version from September 2005 or later");
else
Console.WriteLine("Incorrect behaviour - pre-release runtime (from before September 2005)");
??運算 子
[(??
):如果
object nullObj = null;
object obj = new Object();
return nullObj ?? obj; // returns obj
int? i = null;
int j = i ?? 0; // Unless i is null, initialize j to i. Else (if i is null), initialize j to 0.
C# 3.0的 特性
[C# 3.0
Linq
[from
, where
, select
"from
、where
select
類型 初 始 化 器
[Customer c = new Customer();
c.Name = "James";
Customer c = new Customer() { Name = "James" };
集合 初 始 化 器
[MyList list = new MyList();
list.Add(1);
list.Add(2);
MyList list = new MyList { 1, 2 };
MyList
System.Collections.IEnumerable
且有Add
匿名 類型
[var x = new { Name = "James" };
局部 變數 類型 推斷
[
var x = new Dictionary<string, List<float>>();
Dictionary<string, List<float>> x = new Dictionary<string, List<float>>();
它只
Lambda表 達 式
[Lambda
listOfFoo.Where(
delegate(Foo x)
{
return x.Size > 10;
}
)
可 寫 作
listOfFoo.Where(x => x.Size > 10);
- 如果
只 有 一 個 參 數 ,可 以省略 括 號 (),例 如 item=>{Console.WriteLine("只 有 一 個 參 數 {0}的 Lambda表 達 式 ",item); }; - 如果
只 有 一個返回值的語句,可 以省略 花 括 號 {}、return關 鍵 字 、分 號 ,例 如 item => {return item % 2 == 0;};覆 寫 成 :item =>item %2 == 0; - Lambda
表 達 式 可 以分配給 Func,Action或 Predicate委託 。
自動 化 屬性
[public string Name
{
get;
set;
}
擴充 方法
[public static class IntExtensions
{
public static void PrintPlusOne(this int x)
{
Console.WriteLine(x + 1);
}
}
int foo = 0;
foo.PrintPlusOne();
擴充 方法 只 會 增加 編 譯 器 的 工作 ,但 不 會 影響 程 式 執行 效能 (用 繼承 的 方式 為 一個類型增加特性反而會影響效能)- 如果
原 來 的 類 中有 一 個 方法 ,跟擴充 方法 一 樣 ,那 麼擴充 方法 不 會 被 呼 叫 ,編 譯 器 也不會 提示
分部 方法
[分部 方法 (Partial methods)必須 定義 在 分部 類 (partial classes)中 定義 分部 方法 需要 用 partial做修飾 詞 分部 方法 不 一定總是有執行內容的,也就是 說 定義 的 方法 可 以一句操作語句都沒有分部 方法 返 回 值必須是void分部 方法 可 以是靜態 (static)方法 分部 方法 可 以包含 參 數 ,參 數 可 以包含 以下 修飾 詞 :this,ref,params分部 方法 必須 是 私有 (private)方法
partial class C
{
static partial void M(int i); // defining declaration
}
partial class C
{
static partial void M(int i)
{
dosomething();
}
}
C# 4.0的 特性
[dynamic類型
[C# 4.0
dynamic
dynamic calc = GetCalculator();
int sum = calc.Add(10, 20);
具 名 參 數 與 可 選 參 數
[public StreamReader OpenFile(string path, int bufferSize = 1024)
{ ... }
OpenFile(bufferSize: 4096, path: "foo.txt");
與 COM組 件 互動
[static void Main(string[] args)
{
Word.Application wordApplication = new Word.Application() { Visible = true };
wordApplication.Documents.Open(@"C:\plant.docx", ReadOnly: true);
}
excelObj.Cells[5, 5].Value = "This is sample text";
泛型的 協 變 和 逆 變
[C# 4.0
public interface IComparer<in T>
{
int Compare(T left, T right);
}
public interface IEnumerable<out T> : IEnumerable
{
IEnumerator<T> GetEnumerator();
}
C# 5.0的 特性
[- C# Evolution Matrix
- Async Feature (
補充 : async和 await是 一 對語 法 糖 ,允許 開發 人員 非常 輕 鬆 的 呼 叫 基 於TASK的 非 同 步 編 程 )async-await關 鍵 字 並 不 會 真 的 建立 一 個 執行 緒 池 任務 ,完成 這個動作 依賴 於被呼 叫 方法 中 的 函 式 。這一點在 許多 C#的中 文教 程 中 被 忽 略 ,導 致許多 學習 的 新手 誤 以為await關 鍵 字 會 直接 建立 一個新的執行緒池任務。 - Caller Information
C# 6.0的 特性
[唯 讀 Auto屬性 - Auto
屬性 初 始 設定 式 使用 靜態 - Null -
條件 運算 子 字 串 插值例外 狀況 篩 選 條件 - nameof
運算 式 - Catch
和 Finally區 塊 中 的 Await 索引 初 始 設定 式 集合 初 始 設定 式 的 擴充 方法 改 進 的 多 載 解析
表 達 式 主體 (Expression-bodied)用 於類的 方法 和 唯 讀屬性
[using System;
public class Person
{
public Person(string firstName, string lastName)
{
fname = firstName;
lname = lastName;
}
private string fname;
private string lname;
public override string ToString() => $"{fname} {lname}".Trim(); //返 回 值类型 string
public void DisplayName() => Console.WriteLine(ToString()); //返 回 值类型 void
public string Name => $"{fname} {lname}".Trim();//只 读属性
}
C# 7.0的 特性
[out 變數
[棄元
[
var tuple = (1, 2, 3, 4, 5);
(_, _, _, _, var fifth) = tuple;
var obj = CultureInfo.CurrentCulture.DateTimeFormat;
switch (obj)
{
case IFormatProvider fmt:
Console.WriteLine($"{fmt} object");
break;
case null:
Console.Write("A null object reference");
break;
case object _:
Console.WriteLine("Some object type without format information");
break;
}
if (obj is object _) { ... }
var point = new Point(10, 10);
// 只 要 x, 不 关心 y
point.GetCoordinates(out int x, out _);
void Test(Dto dto)
{
_ = dto ?? throw new ArgumentNullException(nameof(dto));
}
表 達 式 主體 (Expression-bodied)用 於類的 屬性 、構造 器 、終端 子 、索引 器
[using System;
public class Location
{
private string locationName;
public Location(string name) => Name = name; //构造函数
public string Name
{
get => locationName; //get属性
set => locationName = value; //set属性
}
public override string ToString() => GetType().Name;
~Location() => Console.WriteLine($"The {ToString()} finalizer is executing."); //析构函数
private string[] types = { "Baseball", "Basketball", "Football",
"Hockey", "Soccer", "Tennis",
"Volleyball" };
public string this[int i]
{
get => types[i]; //索引 器
set => types[i] = value;
}
}
C# 7.1的 特性
[- async``Main
方法 - default
常 值運算式 推斷 的 tuple項目 名稱
C# 7.2的 特性
[具備 實 值型別 的 參考 語意 無 後 置 具 名 引數 數 值常值中的 前 置 底 線 - private protected
存 取 修飾 詞
C# 8.0的 特性
[可 空 參照 類型 - await yield return
可 非 同 步 返 回 的 迭代器 - Index
索引 類型 和 Range區間 類型 允許 在 聲明 介 面 時 為 介 面 成員 提供 預 設 實現 - 遞迴
的 模 式 匹 配 表 達 式 形式 的 Switch關 鍵 字 在 編 譯 器 可 做類型 推斷 的 情況 下 ,允許 進 一 步 省略 類型 聲明
C# 9的 特性
[新 的 「Record」類型
[優 點 :記錄 類型 是 輕量 級 的 不 可變 類型 ,可 以減少 大 量的 代 碼,可 以按照 結構 和 參照 進行 比較 ;缺點 :需要 實例 化 大量 的 對象 ;
// 默 认不可 变的记录类型
public record Person(string Name, int Age);
// 可 变记录类型
public record MutablePerson(string Name, int Age)
{
public string Name { get; set; } = Name;
public int Age { get; set; } = Age;
}
var person1 = new Person("Alice", 40);
var person2 = new Person("Alice", 40);
Console.WriteLine(person1 == person2); // True 结构相 同
Console.WriteLine(person1.Equals(person2)); // True 结构相 同
Console.WriteLine(ReferenceEquals(person1, person2)); // False, 引用 不同
// 改 变默认的记录! --> 创建一 个新的 记录。
var person3 = person1 with { Age = 43 };
Console.WriteLine(person3 == person1); // False 结构不同
// 解 构 (Destruct) 一 个记录, 将 记录的 属性 提 取 为本地 变量
var (name, age) = person3;
var person4 = new MutablePerson("Alice", 40);
person4.Age = 43;
// 记录类型也可以被继承
public record Citizen(string Name, int Age, string Country) : Person(Name, Age);
var citizen = new Citizen("Alice", 40, "China");
Console.WriteLine(person1 == citizen); // False 类型不同 ;
「init」存 取 子
[init
Student
StudentName
StudentID
public class Student
{
public Student()
{
}
public Student(string studentName,string studentID)
{
StudentName = studentName;
StudentID = studentID;
}
public string StudentName { get; init; } = "Default Name";
public string StudentID { get; init; } = "00000000";
}
如果
Student DemoStudent = new Student();
DemoStudent.StudentName = "Test Name";
而如
Student DemoStudent = new Student() //物件 初 始 化 運算 式
{
StudentName = "Test Name";
StudentID = "0001"
};
Student DemoStudent = new Student("Test Name","0001"); //藉由類型 的 建 構式初 始 化 StudentName以及StudentID。
最 上層 語句 或 稱 頂 級 語句
[using System;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
using System;
Console.WriteLine("Hello World!");
//或 者 简化为一 行 语句:
System.Console.WriteLine("Hello World!");
lambda棄元參 數
[Func<int, int, int> zero = (_, _) => 0;
Func<int, int, int> func = delegate (int _, int _) { return 0; };
只 能 初 始 化 的 設定 器
[Init only setters,
public class InitDemo
{
public string Start { get; init; }
public string Stop { get; init; }
}
// initDemo.Start = "Now"; // Error
// initDemo.End = "Tomorrow"; // Error
var initDemo = new InitDemo
{
Start = "Now",
Stop = "Tomorrow"
};
函 式 指標
[unsafe class FunctionPointer {
static int GetLength(string s) => s.Length;
delegate*<string, int> functionPointer = &GetLength;
}
public void Test() {
Console.WriteLine(functionPointer("test")); // 4;
}
跳 過 本地 初 始 化
[[System.Runtime.CompilerServices.SkipLocalsInit]
static unsafe void DemoLocalsInit() {
int x;
// 注意 , x 没 有 初 始 化 , 输出结果不 确定;
Console.WriteLine(*&x);
}
原生 整數 類型
[協 變 返 回 類型
[
class Person
{
public virtual Person GetPerson() { return new Person(); }
}
class Student : Person
{
public override Student GetPerson() { return new Student(); }
}
模 組 初 始 化 代 碼
[ModuleInitializerAttribute
必須 是 靜態 的 、無 參 數 的 、無 返 回 值的方法 ;不能 是 範式 方法 ,也不能 包含 在 範式 類 中 ;不能 是 私有 函 式 ,必須 是 公開 (public)或 者 內部 (internal)的 函 式 ;
靜態 lambda 表 達 式
[static
分部 方法 擴充
[必須 具有 void返 回 類型 。不能 具有 out參 數 。不能 具有 任 何 可 訪問 性 (隱 式 private )。
初 始 化 表 達 式 的 簡化
[如果
Point p = new(1, 1);
Dictionary<string, int> dict = new();
Point[] points = { new(1, 1), new (2, 2), new (3, 3) };
var list = new List<Point> { new(1, 1), new(2, 2), new(3, 3)};
在 本地 函 式 上 添加 標記
[using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
namespace CoreApp2
{
class Program
{
static void Main(string[] args)
{
[Conditional("DEBUG")]
static void DoSomething([NotNull] string test)
{
System.Console.WriteLine("Do it!");
}
DoSomething("Doing!");
}
}
}
GetEnumerator 擴充
[using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace CoreApp2
{
public static class Extensions
{
public static IEnumerator<T> GetEnumerator<T>(this IEnumerator<T> enumerator) => enumerator;
}
class Program
{
static void Main(string[] args)
{
IEnumerator<string> enumerator = new Collection<string> {"A", "B", "C"}.GetEnumerator();
foreach (var item in enumerator)
{
Console.WriteLine(item);
}
}
}
}
模 式 匹 配 增強
[Type patterns
object obj = new int();
var type = obj switch
{
string => "string",
int => "int",
_ => "obj"
};
Console.WriteLine(type); // int
Relational patterns
class Person
{
public string name;
public int age;
public Person(string a, int b) { name = a;age = b; }
public void Deconstruct(out string a,out int b){a = name;b = age; }
}
class Program
{
static void Main(string[] args)
{
var person1 = new Person("Alice", 40);
var inRange = person1 switch
{
(_, < 18) => "less than 18",
(_, > 18) => "greater than 18",
(_, 18) => "18 years old!"
};
Console.WriteLine(inRange); // greater than 18
}
}
Conjunctive and patterns 邏輯
// And pattern
var person1 = new Person("Alice", 40);
var ageInRange = person1 switch
{
(_, < 18) => "less than 18",
("Zhang Zhimin", _) and (_, >= 18) => "Alice is greater than 18"
};
Console.WriteLine(ageInRange); // Alice is greater than 18
Disjunctive or patterns 邏輯析取
// Or pattern
var person1 = new Person("Alice", 40);
var ageInRange = person1 switch
{
(_, < 18) => "less than 18",
(_, 18) or (_, > 18) => "18 or greater"
};
Console.WriteLine(ageInRange); // 18 or greater
Negated not patterns 邏輯
// Not pattern
var person1 = new Person("Alice", 40);
var meOrNot = person1 switch
{
not ("Alice", 40) => "Not me!",
_ => "Me :-)"
};
Console.WriteLine(meOrNot); // Me :-)
Parenthesized patterns
// Parenthesized patterns
var is10 = new IsNumber(true, 10);
var n10 = is10 switch
{
((_, > 1 and < 5) and (_, > 5 and < 9)) or (_, 10) => "10",
_ => "not 10"
};
Console.WriteLine(n10); // 10
C# 10的 特性
[record struct
[
record struct Point(int X, int Y);
sealed record ToString 方法
[struct 無 參 建 構函式
[用 with新 增 的 匿名 類型 對象
[var x = new { A = 1, B = 2 };
var y = x with { A = 3 };
這裡 y.A
全域 的 using
[檔案範圍 的 namespace
[namespace MyNamespace;
常 數字 串 插值
[const string x = "hello";
const string y = $"{x}, world!";
lambda的 改 進
[lambda 可 以帶 attributes
[f = [Foo] (x) => x; // 给 lambda 设置
f = [return: Foo] (x) => x; // 给 lambda 返 回 值设置
f = ([Foo] x) => x; // 给 lambda 参 数 设置
指定 返 回 值類型
[此前 C#
f = int () => 4;
支援 ref 、in 、out 等 修飾
[f = ref int (ref int x) => ref x; //返 回 一 个参数 的 引用
頭 等 函 式
[
void Foo() { Console.WriteLine("hello"); }
var x = Foo;
x(); // hello
自然 委託 類型
[
lambda
var f = () => 1; // Func<int>
var g = string (int x, string y) => $"{y}{x}"; // Func<int, string, string>
var h = "test".GetHashCode; // Func<int>
CallerArgumentExpression
[
void Foo(int value, [CallerArgumentExpression("value")] string? expression = null)
{
Console.WriteLine(expression + " = " + value);
}
tuple 的 混合 定義 和 使用
[int y = 0;
(var x, y, var z) = (1, 2, 3);
於是 y 就
介 面 支援 抽象 靜態 方法
[.NET 6
泛型 attribute
[在 方法 上 指定 AsyncMethodBuilder
[line 指示 器 支援 行列 和 範圍
[
#line (startLine, startChar) - (endLine, endChar) charOffset "fileName"
// 比 如 #line (1, 1) - (2, 2) 3 "test.cs"
巢 狀 屬性 模 式 匹 配 改 進
[if (a is { X: { Y: { Z: 4 } } }) { ... }
if (a is { X.Y.Z: 4 }) { ... }
改 進 的 字 串 插值
[Source Generator v2
[泛型屬性
[C# 11 System.Attribute
public class GenericAttribute<T> : Attribute { }
靜態 介 面 方法
[C# 11
public interface IGetNext<T> where T : IGetNext<T>
{
static abstract T operator ++(T other);
}
無 符號 右 移 運算 子 >>>
[>>>
,
泛型數學 支援
[System
public static TResult Sum<T, TResult>(IEnumerable<T> values)
where T : INumber<T>
where TResult : INumber<TResult>
{
TResult result = TResult.Zero;
foreach (var value in values)
{
result += TResult.Create(value);
}
return result;
}
字 串 內插中 的 換 行 符
[{
}
內的
原始 字 串 文字
["""
"""
"""
"""
var x = 1;
var y = 2;
var code1 = """int i = 0;""";
var code2 = $"""int x = {x};""";
var code3 = $$"""
#include <stdio.h>
int main(void) {
const char *s = "{y} = {{y}}"; // {y} = 2
return 0;
}
""";
Console.WriteLine($"code1:\n{code1}\n");
Console.WriteLine($"code2:\n{code2}\n");
Console.WriteLine($"code3:\n{code3}\n");
UTF-8 字 串 字面 量
[u8
ReadOnlySpan<byte>
[27]:
列 表 模 式
[[
]
int[] numbers = { 1, 2, 3 };
Console.WriteLine(numbers is [1, 2, 3]); // True
Console.WriteLine(numbers is [1, 2, 4]); // False
Console.WriteLine(numbers is [1, 2, 3, 4]); // False
Console.WriteLine(numbers is [0 or 1, <= 2, >= 3]); // True
數 值 IntPtr
和 UIntPtr
[C# 11 nint
nuint
IntPtr
UIntPtr
(C# 9
改 進 了 方法 組 向 委託 的 轉換
[Sum
SumMethodGroup
static readonly List<int> Numbers = Enumberable.Range(0, 100).ToList();
public int Sum()
{
return Numbers.Where(x => Filter(x)).Sum(); // <- faster
}
public int SumMethodGroup()
{
return Numbers.Where(Filter).Sum(); // <- slower
}
static bool Filter(int number)
{
return number > 50;
}
程 式 的 執行
[C#
標準 化
[自由 軟體基金 會 的 dotGNU Portable.NET(頁 面 存 檔備份,存 於網 際 網 路 檔案館 )- Mono(
頁 面 存 檔備份,存 於網 際 網 路 檔案館 ) - Baltie - C# IDE for children and young Baltie(
頁 面 存 檔備份,存 於網 際 網 路 檔案館 )
範 例
[C# 的 Hello World程 式
[using System;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
實現
[其他 C#
微 軟的轉 軸 專 案 (Rotor Project,目前 稱 為 Shared Source Common Language Infrastructure),提供 了 通用 語 言 執行 層 (Common Language Runtime)的 實 作 與 C#編 譯 器 。但 是 Shared Source Common Language Infrastructure在 2006年 的 2.0版 後 就停止 了 。由 Microsoft贊助 的 Mono專 案 提供 了 C#編 譯 器 ,它提供 了 一 個 開源 C#編 譯 器 、一 個 完 整 的 CLI開源 實現 ,同時 也接近 百分之百地實作了.NET Framework類別 庫 。而Mono後來 衍伸出 由 微 軟認可 的 第 三 方 套件Xamarin。- Dot GNU
專 案 (現 已 停 產 )也提供 了 另一 個 自由 版本 的 C#編 譯 器 ,也提供 了 .NET Framework類別 庫 的 實 作 。
參考 文獻
[- ^ Announcing C# 12. [2023
年 11月18日 ]. - ^ 2.0 2.1 The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.: dotnet/roslyn. November 13, 2019 [2021-08-16]. (
原始 內容存 檔於2021-02-22) –透過 GitHub. - ^ CoreCLR is the runtime for .NET Core. It includes the garbage collector, JIT compiler, primitive data types and low-level classes.: dotnet/coreclr. November 13, 2019 [2021-08-16]. (
原始 內容存 檔於2019-10-14) –透過 GitHub. - ^ Rich Hickey Q&A by Michael Fogus. [2017-01-11].
原始 內容存 檔於2017-01-11. - ^ C# Language Specification (PDF) 4th. Ecma International. June 2006 [2012-01-26]. (
原始 內容 (PDF)存 檔於2012-12-02). - ^ 6.0 6.1 Using C# 3.0 from .NET 2.0. Danielmoth.com. 2007-05-13 [2012
年 10月 4日 ]. (原始 內容存 檔於2012-09-29). - ^
存 档副本 . [2018-09-06]. (原始 內容存 檔於2018-01-22). - ^ 8.0 8.1 8.2 8.3
存 档副本 . [2018-09-06]. (原始 內容存 檔於2018-01-22). - ^ 9.0 9.1 What's new in C# 10. docs.microsoft.com. [2021-11-10]. (
原始 內容存 檔於2022-02-08) (美國 英語 ). - ^ Visual Studio 2022 version 17.0 Release Notes. docs.microsoft.com. [2022-06-24]. (
原始 內容存 檔於2022-08-06). - ^ DeDiv-VR. Visual Studio 2022 version 17.4 Release Notes. learn.microsoft.com. 2024-06-11 [2024-07-15] (
美國 英語 ). - ^ BillWagner. What's new in C# 12. learn.microsoft.com. 2024-06-04 [2024-07-15] (
美國 英語 ). - ^ Murphy, Adrian. Visual Studio 17.8 now available!. Visual Studio Blog. 2023-11-14 [2024-07-15] (
美國 英語 ). - ^ An Introduction to C# Generics. [2020-09-25]. (
原始 內容存 檔於2019-09-24). - ^ Anonymous Methods (C#). [2008-10-24]. (
原始 內容存 檔於2008-04-17). - ^ Covariance and Contravariance in Delegates (C#). [2008-10-24]. (
原始 內容存 檔於2008-10-12). - ^ Tim Anderson. C# pulling ahead of Java - Lead architect paints rosy C# picture. Reg Developer. The Register. 2006-11-14 [2007-01-20]. (
原始 內容存 檔於2007-01-21). - ^ LINQ. Microsoft MSDN. 2007 [2007-08-13]. (
原始 內容存 檔於2007-01-16) (英語 ). - ^ The Mellow Musings of Dr. T : What is a collection?. [2008-10-24]. (
原始 內容存 檔於2008-12-18). - ^ Partial Methods. [2007-10-06]. (
原始 內容存 檔於2007-10-16). - ^
一覽 C# 7.0中 的 新 功 能 . [2016-09-14]. (原始 內容存 檔於2018-10-02). - ^ C# 11
中 的 新 增 功 能 . learn.microsoft.com. [2024-3-19]. (原始 內容存 檔於2024-03-19) (中 文 (中國 大陸 )). - ^
教程 :探索 C# 11功 能 -接 口中 的 静 态虚拟成员. learn.microsoft.com. [2024-3-20]. (原始 內容存 檔於2024-03-19) (中 文 (中國 大陸 )). - ^
位 运算符 和 移 位 运算符 (C#参考 ). learn.microsoft.com. [2024-3-20]. (原始 內容存 檔於2024-03-19) (中 文 (中國 大陸 )). - ^ Preview Features in .NET 6 – Generic Math. devblogs.microsoft.com. [2024-3-20]. (
原始 內容存 檔於2024-02-01) (美國 英語 ). - ^ C#
程 序 设计基 础. docs.eesast.com. [2024-3-20]. (原始 內容存 檔於2024-03-19) (中 文 (中國 大陸 )). - ^ Utf8 Strings Literals. learn.microsoft.com. [2024-3-20]. (
原始 內容存 檔於2024-03-04) (美國 英語 ). - ^ Introducing C# 11: Numeric IntPtr and UIntPtr. anthonygiretti.com. [2024-3-20]. (
原始 內容存 檔於2023-11-30) (美國 英語 ). - ^ C# 11 - Improved Method Group. prographers.com. [2024-3-20]. (
原始 內容存 檔於2023-09-30) (美國 英語 ). - ^ 30.0 30.1 The RyuJIT transition is complete!. microsoft.com. June 19, 2018 [July 20, 2021]. (
原始 內容存 檔於July 19, 2019). - ^ Managed Execution Process. microsoft.com. [July 20, 2021]. (
原始 內容存 檔於December 23, 2017). - ^ coreclr/src/jit/. github.com. [July 20, 2021]. (
原始 內容存 檔於January 9, 2019). - ^ C# Guide. docs.microsoft.com. [2017-11-20]. (
原始 內容存 檔於2022-08-13). - ^ 5.0.8. microsoft.com. [July 20, 2021]. (
原始 內容存 檔於April 23, 2020). - ^ Mitigation: New 64-bit JIT Compiler. microsoft.com. [July 20, 2021]. (
原始 內容存 檔於April 5, 2018).
外部 連結
[- (
英文 )C# Language Specification (MSDN)(頁 面 存 檔備份,存 於網 際 網 路 檔案館 ) - (
英文 )ECMA-334 C# Language Specification (.pdf) - (
英文 )ISO/IEC 23270:2003 C# Language Specification(頁 面 存 檔備份,存 於網 際 網 路 檔案館 ) - (
英文 )Visual Studio Code(頁 面 存 檔備份,存 於網 際 網 路 檔案館 ) - (
英文 )Download .NET(頁 面 存 檔備份,存 於網 際 網 路 檔案館 ) - Visual C# .NET
入門 (MSDN)(頁 面 存 檔備份,存 於網 際 網 路 檔案館 ) - MCS: Mono C#
編 譯 器 (頁 面 存 檔備份,存 於網 際 網 路 檔案館 ) - Visual Studio Community(
頁 面 存 檔備份,存 於網 際 網 路 檔案館 ) - Visual C# Logo(
頁 面 存 檔備份,存 於網 際 網 路 檔案館 ) - C#
教學 (頁 面 存 檔備份,存 於網 際 網 路 檔案館 ) - C#
教材 目錄 (頁 面 存 檔備份,存 於網 際 網 路 檔案館 )
|
|