I don't understand why we can pass Customer while the return type is ActionResult<Customer>. How can we return an object that is different from the method return type?
However, I understand for Task<T> used for asynchronous methods, because c# language provides such a feature internally.
[HttpGet("{id}")]
public ActionResult<Customer> Get(string id)
{
Customer cust = db.Customers.Find(id);
if (cust == null)
{
return NotFound();
}
return cust;
}
Could you give me a simple example how to create our own Wrapper<T> to allow us to write something as follows?
public Wrapper<Foo> AnyMethod()
{
return new Foo();
}