title: Abstract property with public getter, define private setter in concrete class possible?
body: <p>I'm trying to create an abstract class that defines a property with a getter. I want to leave it up to derived classes to decide if they want to implement a setter for the property or not. Is this possible?</p>
  
  <p>What I have so far:</p>
  
  <pre><code>public abstract class AbstractClass {
      public abstract string Value { get; }
      public void DoSomething() {
          Console.WriteLine(Value);
      }
  }
  
  public class ConcreteClass1 : AbstractClass {
      public override string Value { get; set; }
  }
  
  public class ConcreteClass2 : AbstractClass {
      private string _value;
      public override string Value {
          get { return _value; }
      }
      public string Value {
          set { _value = value; }
      }
  }
  
  public class ConcreteClass3 : AbstractClass {
      private string _value;
      public override string Value {
          get { return _value; }
      }
      public void set_Value(string value) {
          _value = value;
      }
  }
  </code></pre>
  
  <p>In <code>ConcreteClass1</code>, I get an error on the <code>set</code>. It can't override <code>set_Value</code> because no overridable set accessor exists in AbstractClass.</p>
  
  <p>In <code>ConcreteClass2</code>, I get an error on both <code>Value</code>'s because a member with the same name is already declared.</p>
  
  <p><code>ConcreteClass3</code> doesn't give an error, but even though Value's set accessor would be compiled into set_Value, it doesn't work the other way around. Defining a <code>set_Value</code> does not mean that <code>Value</code> gets a set accessor. So I can't assign a value to a ConcreteClass3.Value property. I <em>can</em> use ConcreteClass3.set_Value("value"), but that's not what I'm trying to achieve here.</p>
  
  <p>Is it possible to have the abstract class demand a public getter, while allowing an optional setter to be defined in a derived class?</p>
  
  <p><em>In case you'r wondering, this is just a theoretical question. I don't have a real situation where something like this is needed. But I can imagine an abstract class that doesn't care how a property gets set, but that does need to be able to get the property.</em></p>