当前位置: 动力学知识库 > 问答 > 编程问答 >

c# - Auto-properties and immutable types

问题描述:

This question already has an answer here:

  • Is it possible to force an auto-property to use a readonly backing field?

    6 answers

网友答案:

It's not possible to get any better than this with the current version of C#. However, this blog post mentioned a possible new feature in C# 6 discussed by the C# design team at a recent conference - readonly auto properties, which is exactly what you were after.

public int X { get; } = x;  
分享给朋友:
您可能感兴趣的文章:
随机阅读: