c# 7.0 学习笔记

refer : https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-7

out 可以写在里面了

// int result = 0; 不需要写在外面了 
if (!int.TryParse(input, out int result))
{
return null;
} return result;

Local functions, 终于有了, 写习惯 js 的我超爱

[Route("")]
public async Task<IActionResult> Index()
{
string abc = dada();
string dada()
{
return "a";
}
}

getter setter

// Expression-bodied constructor
public ExpressionMembersExample(string label) => this.Label = label; // Expression-bodied finalizer
~ExpressionMembersExample() => Console.Error.WriteLine("Finalized!"); private string label; // Expression-bodied get / set accessors.
public string Label
{
get => label;
set => this.label = value ?? "Default label";
}
上一篇:python协程


下一篇:P3275 [SCOI2011]糖果