title: How to convert object to type?
body: <p>I have a generic method that returns an object. At certain scenarios I would like this object to be a list and therefor I wish to access a list property on the object. In order to be able to do that i need to convert the object to an object type. </p>
  
  <p>I have an object that has data</p>
  
  <pre><code>object obj
  </code></pre>
  
  <p>I am trying:</p>
  
  <pre><code>Type t = obj.GetType();
  
  var t1 = (t)obj;
  </code></pre>
  
  <p>In order to access a list property on the object:</p>
  
  <pre><code> Type t = obj.GetType();
  
    var t1 = (t)obj;
  
    return t1.items.Tolist();
  </code></pre>
  
  <p>How do I do this?</p>
  
  <p>EDIT:</p>
  
  <p>if i would already know the type like for example:</p>
  
  <pre><code>Type t = obj.GetType();
  
  var t1 = (ApiResult&lt;IEnumerable&lt;AlarmLog&gt;&gt;)obj;
  
  return t1.Items.ToList();
  </code></pre>
  
  <p>This would work, but the type is unknown and Im looking to find the type, convert it and then return my desiered list. </p>