title: Replace a dynamic object with T
body: <p>We have a struct which contains dynamic data provided by one source and errors in a fixed format like so:</p>
  
  <pre><code>struct AllOurInfo {
      public dynamic TheData {get;set;}
      public string[] Errors {get;set;}
  }
  </code></pre>
  
  <p>TheData can be various things. A single string or a collection of various types.</p>
  
  <p>The data cannot be structured sometimes (in which case it should remain dynamic, or it can be structured in which case it should be a struct.</p>
  
  <p><strong>How would you go about turning TheData into a non-dynamic object?</strong></p>
  
  <p>I'm looking for something along the lines of this (if that's even possible)</p>
  
  <pre><code>AllOurInfo.TheData = EvaluateData(dData);
  public ParentDataClass EvaluateData(dynamic dData)
  {
      // Figure out the type of data, call the right class
      return new ChildDataClass()
  }
  
  struct AllOurInfo&lt;T&gt; {
      public T TheData {get;set;}  // or whatever class T is rather
      public string[] Errors {get;set;}
  }
  </code></pre>