title: get field by name
body: <p>I am trying to create a function that can return a field from its object.</p>
  
  <p>Here is what I have so far.</p>
  
  <pre><code>public class Base
  {
      public string thing = "Thing";
      public T GetAttribute&lt;T&gt;(string _name)
      {
          return (T)typeof(T).GetProperty(_name).GetValue(this, null);
      }
  }
  </code></pre>
  
  <p>What I would ideally like is to call:</p>
  
  <pre><code>string thingy = GetAttribute&lt;string&gt;("thing");
  </code></pre>
  
  <p>but I have a feeling I got the wrong end of the stick when reading up on this because I keep getting null reference exceptions.</p>