Why Get & Set methods for a property are not separate in C#?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Zeng

    Why Get & Set methods for a property are not separate in C#?

    I wish the Get & Set methods for a property are separate in C#. It would
    be nice if I could do the following:

    class Base
    {
    public bool IsFoo
    {
    set { m_isFoo = value; }
    }

    public bool IsBar
    {
    abstract get;
    virtual set { m_isBar = value; }
    }
    }

    class DerivedA : Base
    {
    public bool IsFoo // Inherit Set and provide Get
    {
    get { /* ..... */ }
    }

    public bool IsBar // inherit the optional Set, must override Get
    {
    override get { /* .... */ }
    }
    }


Working...