【发布时间】:2020-01-14 12:09:39
【问题描述】:
尝试理解 Azure Function 中的默认 return 代码
return name != null
? (ActionResult)new OkObjectResult($"Hello, {name}")
: new BadRequestObjectResult("Please pass a name on the query string or in the request body");
这取决于name 值将执行:
如果name 是null:
return new BadRequestObjectResult("Please pass a name on the query string or in the request body");
否则:
return (ActionResult)new OkObjectResult($"Hello, {name}")
我的问题:
- 为什么
OkObjectResult使用了类型转换,而BadRequestObjectResult却没有? - 为什么我们甚至需要为
OkObjectResult投射?
【问题讨论】:
标签: c# azure-functions