开发者

Is there a way to do this with Auto Properties?

开发者 https://www.devze.com 2022-12-17 20:33 出处:网络
I have code that looks something like this: Card m_currentCard; public Card CurrentCard { get { return m_currentCard; }

I have code that looks something like this:

Card m_currentCard;
public Card CurrentCard {
    get { return m_currentCard; }
    set {
        m_currentCard = value;
        QuestionLabel.Text = CurrentCard.Question;
    }
}

It doesn't do anything special in terms of getting and setting the value of the property, but it does something additional when setting the property. Am I stuck using a separate variable,开发者_如何学JAVA or is there a way to do this with auto properties?


It is not possible to do that using automatically implemented properties.

0

精彩评论

暂无评论...
验证码 换一张
取 消