2021
02-02
02-02
C# 9 新特性——record的相关总结
IntroC#9中引入了record,record是一个特殊类,用它来实现model在有些情况下会非常的好用SamplerecordRecordPerson{publicstringName{get;init;}publicintAge{get;init;}}recordRecordPerson2(stringName,intAge);publicstaticvoidMainTest(){varp1=newRecordPerson(){Name="Tom",Age=12,};Console.WriteLine(p1);varp2=p1with{Age=10};Console.WriteLine(p2);varp3=n...
继续阅读 >