C# 6.0 功能预览 (二)
在Language Feature Status上面看到,其实更新的并不是特别多,为了不会误导看了C# 6.0 功能预览 (一)的园友,现在把官方的更新列表拿了过来,供大家参考
语言功能实现状态
- 存在: 在以前的版本中已经存在
- 完成: 已经在该版本中实现
- 计划: 预计在该版本中
- 可能: 预计可能在该版本中
- 撤销: 可能不在该版本中
- 没有: 该版本中没有
- N/A: 没有意义
功能 |
例子 |
|
Primary constructors |
class Point(int x, int y) { … } |
完成 |
Auto-property initializers |
public int X { get; set; } = x; |
完成 |
Getter-only auto-properties |
public int Y { get; } = y; |
完成 |
Using static members |
using System.Console; … Write(4); |
完成 |
Dictionary initializer |
new JObject { ["x"] = 3, ["y"] = 7 } |
完成 |
Indexed member initializer |
new JObject { $x = 3, $y = 7 } |
撤销 |
Indexed member access |
c.$name = c.$first + " " + c.$last; |
撤销 |
Declaration expressions |
int.TryParse(s, out var x); |
完成 |
Await in catch/finally |
try … catch { await … } finally { await … } |
完成 |
Exception filters |
catch(E e) if (e.Count > 5) { … } |
完成 |
Typecase |
Select Case o : Case s As String : … |
没有 |
Guarded cases |
Select Case i : Case Is > 0 When i Mod 2 = 0 |
没有 |
Partial modules |
Partial Module M1 |
N/A |
Partial interfaces |
Partial Interface I1 |
存在 |
Multiline string literals |
"Hello<newline>World" |
存在 |
Year-first date literals |
Dim d = #2014-04-03# |
N/A |
Binary literals |
0b00000100 |
计划 |
Digit separators |
0xEF_FF_00_A0 |
计划 |
Line continuation comments |
Dim addrs = From c in Customers ' comment |
N/A |
TypeOf IsNot |
If TypeOf x IsNot Customer Then … |
N/A |
Expression-bodied members |
public double Dist => Sqrt(X * X + Y * Y); |
计划 |
Event initializers |
new Customer { Notify += MyHandler }; |
计划 |
customer?.Orders?[5]?.$price |
计划 |
|
Semicolon operator |
(var x = Foo(); Write(x); x * x) |
可能 |
Private protected |
private protected string GetId() { … } |
计划 |
Params IEnumerable |
int Avg(params IEnumerable<int> numbers) { … } |
计划 |
Constructor Inference |
new Tuple(3, "three", true); |
可能 |
"\{p.First} \{p.Last} is \{p.Age} years old." |
可能 |
|
TryCast for nullable |
Dim x = TryCast(u, Integer?) |
存在 |
Delegate combination with + |
d1 += d2 |
存在 |
Implicit implementation |
Class C : Implicitly Implements I |
存在 |
NameOf operator |
string s = nameof(Console.Write); |
计划 |
Strict Module M |
存在 |
|
Dim x = CInt(Math.Truncate(d)) | |
存在 |
|
#Disable Warning BC40008 |
存在 |
|
Checked and Unchecked blocks |
Checked : x += 1 : End Checked |
存在 |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
· SQL Server 2025 AI相关能力初探