有没有一种方法,使只读(不只是私人)自动属性? [英] Is there a way to make readonly (not just private) automatic properties?

查看:75
本文介绍了有没有一种方法,使只读(不只是私人)自动属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自动性能让我替换此代码:

Automatic properties let me replace this code:

private MyType myProperty;
public MyType MyProperty
{
    get { return myPropertyField; }
}



使用此代码:

with this code:

public MyType MyProperty { get; private set; }



在这里和那里一些变化 - 但有没有方法来替换此代码:

with a few changes here and there - but is there a way to replace this code:

private readonly MyType myProperty;
public MyType MyProperty
{
    get { return myPropertyField; }
}

有相似的地方?

推荐答案

没有,但这个想法被跟踪在连接

这篇关于有没有一种方法,使只读(不只是私人)自动属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆