What's New for Visual C# 6.0
https://msdn.microsoft.com/en-us/library/hh156499.aspx
You can get the unqualified string name of a type or member for use in an error message without hard coding a string. This allows your code to remain correct when refactoring. This feature is also useful for hooking up model-view-controller MVC links and firing property changed events.
You can use string interpolation expressions to construct strings. An interpolated string expression looks like a template string that contains expressions. C# creates a string by replacing the expressions with the ToString represenations of the expressions’ results. An interpolated string is easier to understand with respect to arguments than Composite Formatting.
Null-conditional Member Access and Indexing
You can test for null in a very light syntactic way before performing a member access (?.) or index (?[]) operation. These operators help you write less code to handle null checks, especially for descending into data structures. If the left operand or object reference is null, the operations returns null.
You can now initialize specific elements of a collection that supports indexing, such as initializing a dictionary.
Collection Initializer and Add Extension Methods
You can use initializers for collections now when the collection has an Add Extension method. Previously the Add method had to be an instance method.
Overload Resolution
The compiler has improved overload resolution that results in more code just working the way you would expect it to behave. One place where you might stop noticing a problem is when choosing between overloads taking nullable value types, or when passing method groups (instead of lambdas) to overloads that take delegates.
You can use exception filers in catch clauses to determine whether a catch clause should handle the exception. Without this feature, you have to rethrow the exception, which clips the call stack reported in the rethrown exception.
Await in Catch and Finally Blocks
You can use await in catch and finally clauses.
You can initialize auto-properties now similarly to how you initialize fields.
You can define read-only auto-properties now without having to define a property with complete property syntax. You can initialize the property where you declare it or in the type’s constructor.
Function Members with Expression Bodies
You can declare members with expression-bodies of code in the same lightweight syntax you use with lambda expressions. See Methods (C# Programming Guide), Properties (C# Programming Guide), Indexers (C# Programming Guide), and Overloadable Operators (C# Programming Guide).
You can import accessible static members of static types so that you can refer to the members without qualifying the access with the type’s name.
作者:Chuck Lu GitHub |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
2014-11-17 sqlite中的时间
2014-11-17 通过代码来操作SQLite的示例
2014-11-17 System.Data.SQLite未能加载文件或程序集
2014-11-17 Using SQLXML Bulk Load in the .NET Environment