1.参考地址:https://docs.microsoft.com/zh-cn/dotnet/csharp/tutorials/exploration/csharp-7?tutorial-step=5
https://docs.microsoft.com/zh-cn/dotnet/csharp/tutorials/exploration/csharp-6
2.新语法,实例
using System; namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
//c# 新语法
//1.字符串内插 $的使用,代替string.format
//Console.WriteLine("Hello World!");
//var name = "ligenyun";
//var str = $"hello world {name}";
//Console.WriteLine(str); //2.out 关键字变量,在使用的时候声明
//var t = "a1234"; //if(int.TryParse(t, out var r))
//{
// Console.WriteLine(r);
//}
//else
//{
// Console.WriteLine("不是数字");
//} //3.本地函数
//Console.WriteLine(Test(11));
//string Test(int i) => i>2 ? "yes":"no"; //4.元组创建轻量级数据结构
//var t = (aaa : 1, bbb : 2);
//Console.WriteLine(t.aaa); Console.Read();
}
}
}