title: Casting simple generic objects
body: <p>I have a method that I created for simplifying using HttpClient calls. it uses the method     HttpReponse.Content.ReadAsAsync().Result to get the response from the API.</p>
  
  <p>This all works fine. My method looks something like this:</p>
  
  <pre><code>    public static T ExecuteAPIGetRequest&lt;T&gt;(string url, Dictionary&lt;string, string&gt; parameters)
      {
  
          HttpClient client = new HttpClient();
          //basic authentication
  
          var t = new object();
          string baseURL =  "myurl"; 
  
          //Execute request
          HttpResponseMessage response = client.GetAsync(baseURL).Result;
  
          if (response.IsSuccessStatusCode)
          {
              return response.Content.ReadAsAsync&lt;T&gt;().Result;  
          }
          else
          {
              return (T)t;
          }
      }
  </code></pre>
  
  <p>My question is, if the query fails it needs to return an empty type of T. This is fine if its a custom class I have written, but it does not work for objects like string or string[]. Any ideas?</p>
  
  <p>Cheers</p>
  
  <p>NCBL</p>