c#语言特性7.x
2020-12-13 16:27
标签:syn use ret col 表达 sys private sed nbsp c#语言特性7.x 标签:syn use ret col 表达 sys private sed nbsp 原文地址:https://www.cnblogs.com/zlgan/p/11619853.htmlusing System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Language._7._0
{
public class Class1
{
private string label;
public static void run()
{
//out 变量不需要在方法之外事先声明answer
if (int.TryParse("123", out var answer))
Console.WriteLine(answer);
else
Console.WriteLine("Could not parse input");
//元组,需要引入包System.ValueTuple
var alphabetStart = (Alpha: "a", Beta: "b");
Console.WriteLine($"{alphabetStart.Alpha}, {alphabetStart.Beta}");
(int max, int min) = Range();
Console.WriteLine(max);
Console.WriteLine(min);
//数字文本和分隔符
int Sixteen = 0b0001_0000;
int ThirtyTwo = 0b0010_0000;
long BillionsAndBillions = 100_000_000_000;
//默认文本表达式,此处不赋值则编译不通过
Funcstring, bool> whereClause=default;
Console.WriteLine($"默认文本表达式{whereClause}");
//推断元组元素名称
int count = 5;
string label = "Colors used in the map";
var pair = (count, label); // element names are "count" and "label"
}
//ValueTask如果返回Task
上一篇:PHP 数组的值插入
下一篇:冒泡排序/选择排序