title: Declaring int variable with from...to range
body: <p>Can I declare an <code>int</code> variable with a <em>from...to</em> range, so that e.g. the <code>int count</code> can only have the value from <code>0</code> to <code>19</code>? </p>
  
  <p>And when there should be a other value out of range added that just nothing happens, no exception, no new value or something else just ignore it.</p>
  
  <p>I need this variable so often in one class e.g. when I need a value from a list, for the forward and backward buttons and in some methods. I don't want to make an <code>if</code>-clause or call a method every time.</p>
  
  <p>Here is the code showing how I actually handle my problem, but I don't think that it's a good way to do this:</p>
  
  <pre><code>private void btnZurueckData_Click(object sender, RoutedEventArgs e)
  {
      dataFromGuiToObject(index);
      index--;
      if (index &gt; -1)
      {
          resetGUI();
          setDataToGui(zeichnungen, index);
          btnVorData.IsEnabled = true;
      }
      else
      {
          btnZurueckData.IsEnabled = false;
          index++;
      }
  }
  
  private void btnVorData_Click(object sender, RoutedEventArgs e)
  {
      dataFromGuiToObject(index);
      index++;
      if (index &lt; zeichnungen.Count)
      {
          resetGUI();
          setDataToGui(zeichnungen, index);
          btnZurueckData.IsEnabled = true;
      }
      else
      {
          btnVorData.IsEnabled = false;
          btnSpeichern.IsEnabled = true;
          index--;
      }
  }
  </code></pre>