title: Return different types from a single method c# web api
body: <p>I have a web api that returns a customer object when called. However, if an error happens, i want to return an error string. But, how to return different types in a single method of c#.</p>
  
  <pre><code> public IEnumerable&lt;Customers&gt; getCustomersById(string id){
  
          var isAuthenticated = tokenAuthorization.validateToken(access_token);
          if (isAuthenticated)
          {
              List&lt;Customers&gt; customers = new List&lt;Customers&gt;();
              Customers customer = null;
              customer = new Customers();
              customer.kunnr = id;
              customer.name = "John Doe";
              customers.Add(customer);
              return customers;
          }
          else
          {
              return 'Not a valid Access Token';
          }
  
   }
  </code></pre>