C#3.0 Automatic properties with extra logic

前端 未结 2 586
伪装坚强ぢ
伪装坚强ぢ 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.

    0 讨论(0)
  • 2020-12-19 21:36

    Answer: You can't do this with automatic properties.

    0 讨论(0)
提交回复
热议问题