1. .NET 3.0 introduces a new concept of Auto-implemented properties. In short you can do things like: public class MyClass { public int X { get; set; } } Instead of: public class MyClass { private int _x; public int X { get { return _x; } set { _x = value; } } } 2. C# offers the ability to make things like ‘int’ a nullable type. int? x = null; if (x == null || !x.HasValue) { x = 5; } Console.WriteLine(x.ToString()); 3. Aliases make it easier for you to shortcut to your most common called classes. using c = System.Console; using myMethod = System.Reflection.MethodBase; class Program { static void Main(string[] args) { c.WriteLine(myMethod.GetCurrentMethod().Name); } } 4. A favorite shortcut of mine is ‘Ctrl+R+M’ lets you turn any segment of highlighted code into a new method. 5. .NET 4 has a new feature for keeping track of parameters that you may be passing in, you can now prepend values / variables with labels: static void Main(string[] args) { File.Copy(sourceFileName: "Myfile.txt", destFileName: "dest.txt"); }
C# tips
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
Request.ServerVariables[] 學習
leonkin
2020-07-08 11:23:15
Request.Browser 學習
leonkin
2020-07-08 11:23:15
C#序列化對象轉爲爲XML格式字符串
请叫我算术嘉
2020-07-08 10:17:16
System.ArgumentException: 指定字符串與主題所要求的形式不符。 在 System.Net.Mail.Message.set_Subject(String value)
Jimcn2009
2020-07-08 05:52:13
ASP.NET實現登錄驗證碼
HerryDong
2020-07-08 04:12:25
Bootstrap TreeView使用教程三:製作樹形下拉框
HerryDong
2020-07-08 04:12:25
Bootstrap TreeView使用教程一:樹的構造和顯示
HerryDong
2020-07-08 04:12:25
在ASP.NET 2.0中建立站點導航層次
yazoli2002
2020-07-08 03:08:01
ASP.NET MVC使用Spring.NET實現控制反轉和依賴注入(一)
林深时见禄
2020-07-08 02:56:09
簡單實現ASP.NET MVC Ajax無刷新上傳圖片
林深时见禄
2020-07-08 02:56:09
.NETDocX操作Word文件生成圖表
林深时见禄
2020-07-08 02:56:09
ASP.NET Datatable轉Json
首先安裝Newtonsoft.Json 項目引用命名空間:Newtonsoft.Json、Newtonsoft.Json.Converters 代碼部分
林深时见禄
2020-07-08 02:56:09
關於初學ASP.NET技術的學習順序問題
前前後後有很多詢問ASP.NET的學習順序問題,在此就向打算系統學習ASP.NET技術的初學者談談我的建議。 如果你已經有較多的面向對象開發經驗,
yazoli2002
2020-07-08 02:32:31
爲 DropDownList 選項添加背景或樣式
Chenindex
2020-07-07 19:56:44