title: Can I create a reference to a class in C#
body: <p>In my code I set up two different data sources:</p>
  
  <pre><code>_dslocal = new XXX("local"); &lt;- example only
  _dsremote = new XXX("remote"); &lt;- example only
  </code></pre>
  
  <p>Later in the code I retrieve data with a long select that looks similar to this:</p>
  
  <pre><code>var _rowData = (from question in _dslocal.GetAll() &lt;- example only
                  ... many lines of code
  </code></pre>
  
  <p>What I would like to do is to allow a user to switch between local and remote. I
  don't want to have something like:</p>
  
  <pre><code>if ( switch == "local" ) {
    var _rowData = (from question in _dslocal.GetAll() &lt;- example only
                  ... many lines of code
  
  } else {
    var _rowData = (from question in _dsremote.GetAll() &lt;- example only
                  ... many lines of code
  }
  </code></pre>
  
  <p>Maybe this is not a good question but can I do this:</p>
  
  <pre><code>if ( switch == "local" ) {
    var _source = _dslocal;
  } else {
    var _source = _dsremote;
  }
  var _rowData = (from question in _source.GetAll() &lt;- example only
                  ... many lines of code
  </code></pre>