问题描述:

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;  
相关阅读:
Top