C#3.0 Automatic properties with extra logic

前端 未结 2 607
伪装坚强ぢ
伪装坚强ぢ 2020-12-19 20:39

How can I rewrite he following code using C#3.0 automatic properties?

private int _myValue;
        public int MyProperty 
        {
            get { return         


        
2条回答
  •  南笙
    南笙 (楼主)
    2020-12-19 21:33

    No, automatically implemented properties have no declared implementation. Any extended implementation that you wish to provide would have to use a regular property.

    I am not sure what you are looking for in terms of an alternative - the syntax you have used in your question is the alternative.

提交回复
热议问题