檢視 C Sharp 的原始碼
←
C Sharp
跳至導覽
跳至搜尋
由於下列原因,您沒有權限進行編輯此頁面的動作:
您請求的操作只有這個群組的使用者能使用:
使用者
您可以檢視並複製此頁面的原始碼。
'''C#''',{{wikipedia|C_Sharp_(programming_language)|lang=en}} ==技術文件== *[https://docs.microsoft.com/zh-tw/dotnet/csharp/ C# 文件 - 入門、教學課程、參考。 | Microsoft Docs] *[https://github.com/dotnet/csharpstandard GitHub - dotnet/csharpstandard: Working space for ECMA-TC49-TG2, the C# standard committee.] ;其它 *{{wikipedia|C_Sharp_syntax|lang=en}} *{{wikibooks|Category:Shelf:C_Sharp_programming_language|lang=en}} *[http://www.pinvoke.net/ pinvoke.net: the interop wiki!] (在C#中使用Win32 API的各函數定義方式) *[https://www.codeproject.com/Reference/593751/Code-Review-Checklist-and-Guidelines-for-Csharp-De Code Review Checklist & Guidelines for C# Developers] *[https://nietras.com/2022/02/13/dotnet-and-csharp-versions/ .NET and C# Versions - 20th Anniversary ♥ – nietras – Programming, mechanical sympathy, machine learning and .NET ❤.] <!-- ; C# Language Specification *C# 1.2 C:\Program Files\Microsoft Visual Studio 8\VC#\Specifications\1028\C# Language Specification 1.2.doc *C# 2.0 C:\Program Files\Microsoft Visual Studio 8\VC#\Specifications\1028\C# Language Specification 2.0.doc *C# 3.0 C:\Program Files\Microsoft Visual Studio 9.0\VC#\Specifications\1028\CSharp Language Specification.doc *C# 4.0 C:\Program Files\Microsoft Visual Studio 10.0\VC#\Specifications\1028\CSharp Language Specification.doc *C# 5.0 C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC#\Specifications\1028\CSharp Language Specification.docx 或 C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC#\Specifications\1028\CSharp Language Specification.docx //--> ==版本== {| class="wikitable" border="1" |- ! rowspan="2" | 版本 ! colspan="3" | 語言規格 ! rowspan="2" | 日期 ! rowspan="2" | .Net版本 ! rowspan="2" | [[Visual Studio]]版本 |- ! ECMA ! ISO/IEC ! Microsoft |- | C# 1.0 | rowspan="2"|[http://www.ecma-international.org/publications/files/ECMA-ST-WITHDRAWN/ECMA-334,%202nd%20edition,%20December%202002.pdf 2002年12月] | rowspan="2"|[http://download.www.techstreet.com/cgi-bin/pdf/free/378672/ISO+IEC+23270-2003.pdf 2003年四月] | [http://download.microsoft.com/download/a/9/e/a9e229b9-fee5-4c3e-8476-917dee385062/CSharp%20Language%20Specification%20v1.0.doc 2002年1月] | 2002年1月 |[[.NET Framework]] 1.0 |Visual Studio .NET 2002 |- | C# 1.2 | [http://download.microsoft.com/download/5/e/5/5e58be0a-b02b-41ac-a4a3-7a22286214ff/csharp%20language%20specification%20v1.2.doc 2003年10月] | 2003年4月 |.NET Framework 1.1 |Visual Studio .NET 2003 |- | C# 2.0 | [http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-334.pdf 2006年6月] | [http://standards.iso.org/ittf/PubliclyAvailableStandards/c042926_ISO_IEC_23270_2006(E).zip 2006年9月] | [http://download.microsoft.com/download/9/8/f/98fdf0c7-2bbd-40d3-9fd1-5a4159fa8044/csharp%202.0%20specification_sept_2005.doc 2005年9月] | 2005年11月 |.NET Framework 2.0<br/>.NET Framework 3.0 |Visual Studio 2005 |- | C# 3.0 | colspan="2" rowspan="2" {{no|None}} | [http://download.microsoft.com/download/3/8/8/388e7205-bc10-4226-b2a8-75351c669b09/CSharp%20Language%20Specification.doc 2007年8月] | 2006年11月 |.NET Framework 2.0 (Except LINQ)<br/>.NET Framework 3.0 (Except LINQ)<br/>.NET Framework 3.5 |Visual Studio 2008 |- | C# 4.0 | | 2010年4月 |.NET Framework 4 |Visual Studio 2010 |- | C# 5.0 | [https://www.ecma-international.org/publications/files/ECMA-ST/ECMA-334.pdf 2017年12月] | [https://standards.iso.org/ittf/PubliclyAvailableStandards/c075178_ISO_IEC_23270_2018.zip 2018年12月] | [https://www.microsoft.com/en-us/download/details.aspx?id=7029 2013年6月] | 2012年8月 |.NET Framework 4.5 |Visual Studio 2012/2013 |- | C# 6.0 | colspan="2" rowspan="8" {{no|None}} | [https://docs.microsoft.com/zh-tw/dotnet/csharp/language-reference/language-specification/introduction C# 6.0 草稿規格] | 2015年7月 |.NET Framework 4.6<br/>.NET Core 1.0<br/>.NET Core 1.1 |Visual Studio 2015 |- | C# 7.0 | [https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-7.0/ Specification proposal] | 2017年3月 |.NET Framework 4.7 |Visual Studio 2017 |- | C# 7.1 | [https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-7.1/ Specification proposal] | 2017年8月 |.NET Core 2.0 |Visual Studio 2017 (Ver 15.3) |- | C# 7.2 | [https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-7.2/ Specification proposal] | 2017年11月 | |Visual Studio 2017 (Ver 15.5) |- | C# 7.3 | [https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-7.3/ Specification proposal] | 2018年5月 |.NET Core 2.1<br/>.NET Core 2.2<br/>.NET Framework 4.8 |Visual Studio 2017 (Ver 15.7) |- | C# 8.0 | [https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-8.0/ Specification proposal] | 2019年9月 |.NET Core 3.0<br/>.NET Core 3.1 |Visual Studio 2019 (Ver 16.3) |- | C# 9.0 | [https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-9.0/records/ Specification proposal] | 2019年9月 |.NET 5.0 |Visual Studio 2019 (Ver 16.8) |- | C# 10.0 | [https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-10.0/record-structs Specification proposal] | 2021年11月 |.NET 6.0<br/>.NET 6.0.1 |Visual Studio 2022 (Ver 17.0) |- |} ==相關工具== * [http://labs.developerfusion.co.uk/convert/vb-to-csharp.aspx Convert VB.NET to C#] * [http://www.carlosag.net/tools/codetranslator/ Code Translation for .NET (C#<->VB.NET)] * [http://blog.darkthread.net/blogs/darkthreadtw/archive/2008/07/11/mini-csharp-lab-1-3.aspx Mini C# Lab] - [http://www.codeplex.com/minicsharplab Mini C# Lab - codeplex] <!-- ==討論區== * [http://www.programmer-club.com/pc2020v5/forum/forumN.asp?board_pc2020=csharp 程式設計俱樂部] * [http://www.purecs.net/forum8/index1.aspx pure C# 技術社群 - C#] * [http://forums.microsoft.com/MSDN-CHT/ShowForum.aspx?ForumID=233&SiteID=14 MSDN討論區 - C#] //--> ==FAQ== ===跨語言整合=== ;JavaScript *[http://javascriptdotnet.codeplex.com/ Javascript .NET] *[http://jurassic.codeplex.com/ Jurassic] is an implementation of the ECMAScript language and runtime. *[http://clearscript.codeplex.com/ ClearScript] - supports JavaScript (via V8 and JScript) and VBScript. *[https://github.com/sebastienros/jint Jint - Javascript Interpreter for .NET] **[http://jint.codeplex.com/ Jint] - (舊版專案) ===C#之謎(數字後的m)=== * 2 / 1000 等於 0 (輸出成Int32,因為變成整數除整數?) * 2 / 1000m 等於 0.002 (輸出成Decimal) ===自訂控制項的DataBinding=== * [http://dotnetframework.blogspot.com/2007/07/user-controldatabinding.html 如何讓你的自訂控制項(User Control)可以支援DataBinding? ] ===GC(記憶體回收)=== *相關: **[http://msdn.microsoft.com/zh-tw/library/system.idisposable.dispose.aspx IDisposable.Dispose 方法] **[http://msdn.microsoft.com/zh-tw/library/xe0c2357.aspx GC.Collect 方法] System.GC.Collect(); ===使用VB.Net的物件或函數在C#=== * 在C#之中使用VB.Net的 Left()、Mid()、Right()……等字串函數。 *# 專案設定中,把 Microsoft.VisualBasic 加入參考。 *# using Microsoft.VisualBasic; *# 把 Left() 改成 Strings.Left() 來用。 *# 需注意在C#中,字串的字元索引是從0開始算的,而VB.NET是從1開始算的。 * 在C#之中使用VB.Net的 My 的命名空間。 : [http://www.codeproject.com/KB/cs/MyNamespace.aspx Using the VB.net My namespace in C# .net 2.0] ===Lambda 運算式=== {{main|Lambda#應用}} ===WebBrowser=== * [http://www.cnblogs.com/cai9911/archive/2008/03/05/1091443.html 从WebBrowser中取得Cookie 和 WebClient设置cookie!] : 需要先 using System.Net; 才能用 * [http://hi.baidu.com/zhitenglin/blog/item/5d1614f3b09fe6cc0a46e011.html C# WebBrowser强制使新窗口网页只在WebBrowser打开] : 只對超連結有效,對於使用JavaScript去做window.open的無效 ===關於enum=== ;判斷字串是否為enum裡定義過的 *{{msdn|System.Enum.IsDefined}} ;字串轉enum *{{msdn|System.Enum.Parse}} *{{msdn|System.Enum.TryParse}}(.Net Framework 4.0以後才有) *或是 <source lang="csharp"> //版本1 private bool TryParseEnum<T>(string valueToParse, out T returnValue) { if (Enum.IsDefined(typeof(T), valueToParse)) { returnValue = (T)Enum.Parse(typeof(T), valueToParse); return true; } returnValue = default(T); return false; } //版本2 (需要 using System.ComponentModel; ) private bool TryParseEnum<T>(string valueToParse, out T returnValue) { if (Enum.IsDefined(typeof(T), valueToParse)) { TypeConverter converter = TypeDescriptor.GetConverter(typeof(T)); returnValue = (T)converter.ConvertFromString(valueToParse); return true; } returnValue = default(T); return false; } </source> ===執行外部執行檔=== {{main|執行外部執行檔 (C#)}} ===遠端檔案下載=== * 透過 System.Net.WebClient 從遠端的 Web-Server 下載檔案。 <source lang="csharp"> using System.Net; Uri UriSrc = new Uri(strSrcUrl); // Create a new WebClient instance. using (WebClient objWebClient = new WebClient()) { if (IsAsync == true) objWebClient.DownloadFileAsync(UriSrc, strFilename); else objWebClient.DownloadFile(UriSrc, strFilename); } </source> ===取得目前執行檔的檔名與路徑=== <source lang="csharp"> using System; using System.Diagnostics; [DllImport("user32.dll")] private static extern IntPtr GetWindowThreadProcessId(IntPtr hWnd, IntPtr ProcessId); private string GetCurrentProcessFileName() { return Process.GetCurrentProcess().MainModule.FileName; } private string GetWindowModuleFileName(IntPtr hwnd) { uint pid = 0; GetWindowThreadProcessId(hwnd, out pid); return Process.GetProcessById((int)pid).MainModule.FileName; } </source> ===宣告結構陣列=== *[https://stackoverflow.com/questions/309496/initializing-an-array-of-structs-in-c-sharp Initializing an Array of Structs in C#] ===C#的特殊應用=== ;驅動程式 *[https://github.com/VollRagm/KernelBypassSharp GitHub - VollRagm/KernelBypassSharp: C# Kernel Mode Driver to read and write memory in protected processes] ;EFI *[https://github.com/MichalStrehovsky/zerosharp GitHub - MichalStrehovsky/zerosharp: Demo of the potential of C# for systems programming with the .NET native ahead-of-time compilation technology.] ===標準資料流=== *[https://docs.microsoft.com/zh-tw/dotnet/api/system.console Console 類別 (System) | Microsoft Docs] *[https://docs.microsoft.com/zh-tw/dotnet/api/system.diagnostics.process.standardinput Process.StandardInput 屬性 (System.Diagnostics) | Microsoft Docs] *[https://docs.microsoft.com/zh-tw/dotnet/api/system.diagnostics.process.standardoutput Process.StandardOutput 屬性 (System.Diagnostics) | Microsoft Docs]* *[https://docs.microsoft.com/zh-tw/dotnet/api/system.diagnostics.process.standarderror Process.StandardError 屬性 (System.Diagnostics) | Microsoft Docs] ==相關== *[[.NET Library]] [[分類:.NET]] [[Category:程式語言]] [[Category:C#]] [[分類:ISO]]
此頁面使用了以下模板:
模板:Main
(
檢視原始碼
)
模板:Msdn
(
檢視原始碼
)
模板:No
(
檢視原始碼
)
模板:Wikibooks
(
檢視原始碼
)
模板:Wikipedia
(
檢視原始碼
)
返回「
C Sharp
」頁面
導覽選單
個人工具
登入
命名空間
頁面
討論
變體
視圖
閱讀
檢視原始碼
檢視歷史
更多
搜尋
導覽
首頁
社群入口
新聞動態
新聞直播
近期變更
Online IDE
分類
程式語言
資料結構
演算法
技術
軟體
SQL資料庫
網站套件
免費資源
副檔名
檔案格式
分類
其他
動畫
漫畫
小說
小說導讀
驅動程式
購物用
求職網站
推薦書單
線上學習
技術類News或部落格
Microsoft devblogs
網頁技術News
資料技術News
安全性相關News
MS-MVP
藍色小舖認證專家
經營行銷類部落格
工具
連結至此的頁面
相關變更
特殊頁面
頁面資訊