C# 6.0 和VB.NET 14 新特性(翻译)

来源:互联网 发布:mac vscode c语言 编辑:程序博客网 时间:2024/05/16 15:00

原文标题:Languages features in C# 6 and VB 14

原作者:Anthony D. Green   
原文地址:https://github.com/dotnet/roslyn/wiki/Languages-features-in-C%23-6-and-VB-14

  • 已存在: 在以前发行的版本中已经存在此特性
  • 新增: 本次版本新增的特性
  • 计划中: 计划在此版本中增加或实现的特性
  • 无: 在此版本中没有此特性,也没有计划增加此特性。
  • N/A: 对这种语言没有实际意义,不会为其增加此特性。

Please note that everything is still subject to change - this is a preview after all. However, we are reasonably confident about the overall feature set at this point.已经正式发布了

下表中列举了Visual Studio 2015RC中新增的特性 . 查看详细解释,请点击:

  • New Language Features in C# 6
  • New Language Features in VB 14
特性例子C#VB属性自动初始化public int X { get; set; } = x;新增已存在只读属性自动初始化public int Y { get; } = y;新增新增只有get的属性可以初始化赋值Y = 15新增新增静态引用using static System.Console; … Write(4);新增已存在筛选器自动初始化new JObject { ["x"] = 3 }新增无catch/finally中的awaittry … catch { await … } finally { await … }新增异常分离器catch(E e) when (e.Count > 5) { … }新增已存在分部模块Partial Module M1N/A新增分部接口Partial Interface I1已存在新增字符串换行符?"Hello<newline>World"已存在新增以年份开头的日期Dim d = #2014-04-03#N/A新增在隐式中添加注释Dim addrs = From c in Customers ' commentN/A新增TypeOf ... IsNot ...If TypeOf x IsNot Customer Then …N/A新增表达式成员public double Dist => Sqrt(X * X + Y * Y);新增Null引用运算符customer?.Orders?[5]新增新增字符串插值模板$"{p.Name} is {p.Age} years old."新增新增nameof 运算符string s = nameof(Console.Write);新增新增#pragma (可运行的标记)#Disable Warning BC40008新增新增Smart name resolution
(更先进的名称解析) N/A新增具有读写功能的属性可以实现只读属性的接口成员 已存在新增#Region inside methods
(不知道是干嘛的) 已存在新增Overloads inferred from Overrides
推算重载? N/A新增CObj in attributes 已存在新增CRef and parameter name 已存在新增Extension Add in collection initializers 新增已存在Improved overload resolution 新增N/A
0 0
原创粉丝点击