c#特性
作者:互联网
//不可修改的记录类 public record Person(string name); //可修改的记录类 public record struct Person(string name); //带内属性的 public record struct Person(string name) { public List<string> Nums { get; init; } = default!; }
//调用使用, 使用with赋值
Person p1 = new("aaa") { Nums = new List<string>() { "1", "2" } }; Person p2 = p1 with { name = "bbbb" };
标签:string,record,c#,struct,特性,Person,public,name 来源: https://www.cnblogs.com/xyunp/p/16394412.html