title: Variable is a type, which is not valid in the given context
body: <p>I have an interface, called <code>IUser</code></p>
  
  <p>I have two models, <code>User</code> and <code>Guest</code> and both of them implements <code>IUser</code></p>
  
  <p>I have a class, called <code>CardOut</code> what has two properties, <code>Card</code> and <code>User</code></p>
  
  <p>Here is the constructor of the <code>CardOut</code> class:</p>
  
  <pre><code>public CardOut(Interfaces.IUser User, Card Card) {
      this.User = User;
      this.Card = Card;
  }
  </code></pre>
  
  <p>I am getting out some rows from the database, and based on the type of a cell, I am creating a <code>User</code> or a <code>Guest</code>.</p>
  
  <pre><code>foreach (IDictionary&lt;string, string&gt; row in rows) {
      if (row["type"] == "xxx") {
          User UserValue = new User();
          UserValue.buildById(int.Parse(row["user_id"]));
      } else {
          Guest UserValue = new Guest();
          UserValue.buildById(int.Parse(row["id"]));
      }
      Card Card = new Card();
      Card.buildCardByIndex(int.Parse(row["cardindex"]));
      CardOut CardOut = new CardOut(UserValue, Card);  //Here is the error
  }
  </code></pre>
  
  <p>When I want to instantiate a new <code>CardOut</code> object I am getting this error:</p>
  
  <blockquote>
    <p>Error CS0103  The name 'UserValue' does not exist in the current context  </p>
  </blockquote>
  
  <p>How can I solve it? I can not create it outside of the if condition, because I do not know, what class should I instantiate.</p>