[英]Is there a way to get F#'s constructor-parameters-are-automatically-immutable-private-members feature in C#?
In F#, the constructor parameters are automatically saved as immutable fields in the class without having to write the declaration of the field or the copying of the constructor parameter to the field in the constructor. 在F#中,构造函数参数自动保存为类中的不可变字段,而不必编写字段声明或将构造函数参数复制到构造函数中的字段。
Is there any way to mimic this functionality in C#? 有没有办法在C#中模仿这个功能? Is there a reason why a future version of C# couldn't have this feature (ie is there some fundamental limitation of the existing language that conflicts with this feature)?
是否存在未来版本的C#无法具备此功能的原因(即现有语言是否存在与此功能冲突的某些基本限制)?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.