title: Generic method with implicit cast to Guid
body: <p>I have actually a method for reading a value from a special data row of an Feature object:</p>
  
  <pre><code>    private static T GetRowValueByMethod&lt;T&gt;(Feature feature, string fieldName)
      {
          return (T) feature.GetDataRow(fieldName)[fieldName];
      }
  </code></pre>
  
  <p>This works fine for most values, but with <code>Guid</code> I have a problem. If the field contains a <code>System.Guid</code> object, then everything is fine. But if it contains a string value then i got an error, because Guid is not castable implicit from string.</p>
  
  <p>To get a <code>Guid</code> object from a string it is necessary to create a new Guid object by Guid constructor.
  But returning a <code>Guid</code> object is not allowed here.
  Creating a new <code>T</code> object is not possible.
  Creating a <code>Guid</code> object and casting to <code>T</code> is also not possible. So what to do?</p>
  
  <p>I tried something like that, but this does not work (caution: fake code)</p>
  
  <pre><code>    private static T GetRowValueByMethod&lt;T&gt;(Feature feature, string fieldName)
      {
          var obj = feature.GetDataRow(fieldName)[fieldName];
          if (obj.ToString().IsAGuid())
          {
              return (T) new Guid(obj.ToString());
          }
  
          return (T) obj;
      }
  </code></pre>
  
  <p>Does anyone have a good solution for this?</p>