| 領域 | 關鍵命名空間 | 說明 |
|---|---|---|
| 基礎型別 | System, System.Collections.Generic | Object, String, Array, List, Dictionary, Span |
| IO/檔案 | System.IO, System.IO.Compression | Stream, File, Path, ZipArchive |
| 網路/HTTP | System.Net, System.Net.Http, System.Net.Sockets | HttpClient, TcpListener, Socket, DNS |
| 資料存取 | System.Data, Microsoft.Data.SqlClient | ADO.NET, SqlConnection, DataTable |
| XML/JSON | System.Xml, System.Text.Json | XmlDocument, JsonSerializer, LINQ to XML |
| 執行緒/非同步 | System.Threading, System.Threading.Tasks | Task, Parallel, Async/Await, Channel |
| 反射/發射 | System.Reflection, System.Reflection.Emit | Type, Assembly, MethodInfo, ILGenerator |
| 安全/加密 | System.Security.Cryptography | AES, RSA, SHA256, X509Certificate2 |
| 文字/正則 | System.Text, System.Text.RegularExpressions | StringBuilder, Regex, Encoding |
| 診斷/記錄 | System.Diagnostics, Microsoft.Extensions.Logging | Activity, Stopwatch, ILogger |
Microsoft.Extensions.*, System.*, 社群套件| 技術 | 支援範圍 | 現狀 |
|---|---|---|
| .NET Framework | Windows Only | 維護模式 (4.8.1 最後版本) |
| .NET Core / .NET 5+ | Windows, Linux, macOS, ARM64 | 主流跨平台 |
| Mono | 行動裝置、遊戲主機、WebAssembly | 整合進 .NET 6+ |
| Blazor WebAssembly | 瀏覽器 (WASM) | 客戶端 C# 運行 |
| MAUI | 跨平台 UI (Win/Mac/iOS/Android) | 統一 UI 堆疊 |
internal static class NativeMethods {
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern bool CloseHandle(IntPtr hObject);
[DllImport("user32.dll", SetLastError = true)]
public static extern int MessageBox(IntPtr hWnd, string text, string caption, uint type);
}
// 使用
NativeMethods.MessageBox(IntPtr.Zero, "Hello", "P/Invoke", 0);
ComVisibleAttribute)Type Library Importer (tlbimp) / Exporter (tlbexp).NET 基礎類別庫提供全面、現代化、跨平台的 API 覆蓋。互通性三大維度:語言 (CTS/CLS/DLR)、平台 (.NET 5+ 全平台)、標準 (開放協定/雲原生)。P/Invoke、C++/CLI、COM Interop 解決既有資產整合。選擇 .NET 即獲得豐富生態系與長期演進保障。