title: Passing unknown type as parameter to a method then casting to that type later on
body: <p>I need to create a method that accepts an unknown type and then later uses that type to access an object.</p>
  
  <p>A little more detail. I have a DevEx grid and I'm using GetRow to get a record. GetRow must be of the type of Linq class object to access the properties of the record. I'm trying to create a generic method that will allow me to pass in the type of Linq object and then dynamically cast the result from GetRow to that object. I will then get the column fieldname to access the properties like so (objectType is the unknown type):</p>
  
  <pre><code>void DoGrid (GridView gv, objectType)
  {    
  
      PropertyInfo[] properties = objectType.GetProperties();
  
      foreach (GridColumn col in gv.Columns)
          {
               if (col.Visible)
               {
                   PropertyInfo property = properties.Where(prop =&gt; prop.Name == col.FieldName).FirstOrDefault();
                   ...
               }
          }
  
  }
  </code></pre>