| C# / .NET | C++ (標準庫/跨平台) | 備註 |
|---|---|---|
| WinForms / WPF | Qt / wxWidgets / Dear ImGui / 標準 I/O | C++ 無內建 GUI,需引入第三方庫 |
| 垃圾回收 (GC) | RAII / 智慧指標 std::unique_ptr, std::shared_ptr | 手動管理生命週期,零成本抽象 |
| 反射 / Attribute | 無原生支援,用模板特化/宏/外部工具 (RTTR) | 編譯期完成,執行期無中繼資料 |
| 委派 / 事件 / Lambda | std::function, std::bind, Lambda (C++11) | 語法相近,但型別擦除有額外開銷 |
| 非同步 / Task / await | std::future, std::async, Coroutine (C++20) | C++20 協程才接近 await 體驗 |
字串 string | std::string (UTF-8) / std::wstring (UTF-16/32) | 編碼需自行處理,建議全專案 UTF-8 |
集合 List<T>, Dictionary<K,V> | std::vector, std::unordered_map | 介面相似,無泛型協變/逆變 |
| LINQ | 範圍演算法 <algorithm>, <ranges> (C++20) | 管道風格需 C++20 ranges |
class → C++ std::shared_ptr<Class>;struct → C++ struct (值語意)。DllExport + P/Invoke 互呼。DateTime (tick, 100ns) vs C++ std::chrono::system_clock (ns) —— 單位換算錯誤會導致時間漂移。decimal (128-bit 定點) 在 C++ 無對應型別,需用 boost::multiprecision::cpp_dec_float_50 或自行實作定點數。std::expected (C++23) / std::optional + 錯誤碼。wchar_t),跨平台庫用 UTF-8,邊界處需轉換。遷移非單純語法轉換,而是架構重構良機。建議「邏輯先行,UI 後補」,引入單元測試與 CI,確保行為一致性。