N kinds of writing fennel beans
the using the System; the using the System.Collections.Generic; the using the System.Linq; the using System.Net.Http; the using the System.Text; the using System.Threading.Tasks; // static import (static method for introducing a single category of the using static the System.Math ; the using static System.String the; namespace Language._6._0 { public class Student { // read-only attribute public String FirstName { GET ;} // automatic initialization expression property public String the LastName {GET ; SET ;} = " Wang " ; // the Expression-bodied function member // the string interpolation public the override String the ToString () => $ " {the LastName FirstName} {} " ; public String the FullName => $ " {FirstName the LastName} {} " ; public Student (Student OTHER) { // null operator conditions the this ? .lastName = OTHER .lastName; // equivalent = OTHER == null null this.LastName: other.LastName;? //Null coalescing operator (??) to the left of the operator is not empty then return to the left, or the right to return the this .lastName = OTHER .lastName ??? " The Test " ; Console.WriteLine ( the this .lastName); Console.WriteLine ( the this .ToString ()); // exception filter the try { the throw new new HttpRequestException ( " aaaa301 " ); } the catch (System.Net.Http.HttpRequestException E) When (e.Message.Contains ( " 301 " )) { Console. the WriteLine ( " Site Moved"); } //nameof Console.WriteLine(nameof(this.FirstName));//FirstName //使用索引器初始化关联集合 Dictionary<int, string> webErrors = new Dictionary<int, string> { [404] = "Page not Found", [302] = "Page moved, but left a forwarding address.", [500] = "The web server can't come out to play today." }; Console.WriteLine(webErrors[404]);//Page not Found // Task.Run(()=>this.ToString()); } } }