title: Force child class to initialize fields
body: <p>I have abstract base class that contains some fields and some methods that act on these fields. For example:</p>
  
  <pre><code>public abstract class A
  {
      protected double _field;
  
      public double SquaredField { get { return _field * _field; } }
  
      ... some other abstract methods
  }
  </code></pre>
  
  <p>I want to impose that all children of A initialize _field in their constructors</p>
  
  <pre><code>public class B : A
  {
      public B(double field)
      {
           _field = Math.Sqrt(field);
      }
  
      ... some other method implementations
  }
  </code></pre>
  
  <p>What's the correct pattern to achieve this?</p>
  
  <p><strong>-- EDIT</strong></p>
  
  <p>What I ended up doing is:</p>
  
  <pre><code>public abstract class A
  {
      protected readonly double _field;
  
      public A(double field)
      {
           _field = field;
      }
  
      public double SquaredField { get { return _field * _field; } }
  
      ... some other abstract methods
  }
  
  
  public class B : A
  {
      public B(double field) : base(field)
      {
      }
  
      public static B CreateNew(double val)
      {
           return new B(Math.Sqrt(field));
      }
  
      ... some other method implementations
  }
  </code></pre>