namespace _6._0新特性
{
using static _6._0新特性.Statics.StaticClass;
class Program
{
static void Main(string[] args)
{
// 特性01 静态的using 声明
//之前的调用方式 类名 +方法名
_6._0新特性.Statics.StaticClass.TestFunc();
// 在加了 using static _6._0新特性.Statics.StaticClass; 引用之后,直接调用 ,如下
TestFunc();
}
}
  // 特性02  表达式体方法,如下简写方式
//public string GetNewString(string str)
//{
// return $"{str}newString";
//}
public string GetNewString(string str) => $"{str}newString";
//调用上面的方法
public string GetNewString1(string str) => GetNewString("");

  

 //特性3  Get 方法的写法
private string _name;
public string Name => _name;
 //特性4 Set 方法 设定初始值
public string Age { get; set; } = "";
public int Age1 { get; set; } = default(Int32);
  //特性05  只读自动属性
private readonly string _sex;
public string Sex => _sex;
static void Main(string[] args)
{ //特性06 nameof
Console.WriteLine($"{nameof(Main)},{nameof(args)}"); //输出 Main,args
}
 //特性07
//if (str != null)
// return str.ToString() + "22";
//else return str;
// 等同于下面的语法
return str?.ToString() + "";
  // 特性08 字典得初始化
var dic = new Dictionary<string, string>();
dic.Add("", "");
// 以下新的写法
var dict = new Dictionary<string, string>
{
[""] = "",
[""] = ""
};
 // 特性09  异常的过滤
try
{ }
catch (Exception ex) when (ex.GetType() == typeof(ArgumentException))
{
//
}
// 特性10 可以在 catch 中使用Await 关键字

最新文章

  1. 传输层(3)-缓冲区大小及限制、TCP输出
  2. ECharts-基于Canvas,纯Javascript图表库,提供直观,生动,可交互,可个性化定制的数据可视化图表
  3. September 2nd 2016 Week 36th Friday
  4. Redis在Windows下的安装和使用
  5. KeyBord事件分发和接收简要过程代码示例
  6. DISPLAY_ITEM built-in in Oracle D2k Forms
  7. 【转】C/C++除法实现方式及负数取模详解
  8. ASP.NET 资料下载
  9. (转)ios跳转到通用页面
  10. 通过取父级for循环的i来理解闭包,iife,匿名函数
  11. 图论基础之Dijkstra算法的初探
  12. android 网络获取json并且显示(2)
  13. 消息队列_MSMQ(2)简单应用
  14. go语言环境安装
  15. (FZU 2150) Fire Game (bfs)
  16. 手机端rem 用法
  17. 金蝶特性配置(超级BOM)
  18. 20155318 《网络攻防》Exp5 MSF基础应用
  19. golang 实现海明距离 demo
  20. SICP-练习2.17

热门文章

  1. 【leetcode】433. Minimum Genetic Mutation
  2. php 系统函数
  3. controllerpom
  4. 超微主板IPMI的使用
  5. ueditor 图片粘贴上传,实现图文粘贴,图片自动上传
  6. BDE(一款数据库引擎,通过它可以连接不同数据库)
  7. window 2008/2012计划任务配置
  8. [CSP-S模拟测试]:tree(DP)
  9. 专家揭秘:STM32启动过程全解
  10. xml解析用正则解决没有标签的文本的解析不出异常