博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
What's New for Visual C# 6.0
阅读量:5229 次
发布时间:2019-06-14

本文共 2475 字,大约阅读时间需要 8 分钟。

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 .

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.

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.

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 , , , and .

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.

 

转载于:https://www.cnblogs.com/chucklu/p/4972462.html

你可能感兴趣的文章
(转)php简单工厂模式实例讲解
查看>>
图片轮播
查看>>
KeepCode 4 解题报告
查看>>
数位统计/数位DP 专题
查看>>
[原创]cocos2d-x + Lua接入iOS原生SDK的实现方案
查看>>
转: python 操作串口
查看>>
【watcher】 #02 c# 中实现时间戳等,日期数字及大概率绝对随机数 实现
查看>>
如何优雅地发布Hexo博客
查看>>
cocosbuilder3.0使用小记
查看>>
winform用户控件、动态创建添加控件、timer控件、控件联动
查看>>
web前端基础知识学习笔记
查看>>
使用grunt js进行js的链接和压缩
查看>>
java 操作clob
查看>>
CF R274 Div2 E Riding in a Lift DP
查看>>
写给笨蛋徒弟的学习手册(3)—C#中15个预定义数据类型
查看>>
诗、赏析
查看>>
window对象和全局变量,局部变量的疑问
查看>>
退役快乐
查看>>
计算半径为3.0的圆周长和面积并输出结果。把圆周率π定义为常量,半径定义为变量,然后进行计算并输出结果。...
查看>>
什么是JSON
查看>>