public ActionResult Edit(int id)
=> Json(_itemMasterBL.GetItemMaster()?.Where(x => x.Id == id).FirstOrDefault(), JsonRequestBehavior.AllowGet);
I have the above piece of code as expression-bodied method (c# 6.0).
But in visual studio 2017 quick actions (ctrl + .) it makes this suggestion:
IDE0022: use block body for methods as follows:
public ActionResult Edit(int id)
{
return Json(_itemMasterBL.GetItemMaster()?.Where(x => x.Id == id).FirstOrDefault(), JsonRequestBehavior.AllowGet);
}
What is the meaning of this suggestion? Is it proposing that this change should be preferred for some reason? Or is it just offering the possibility as a convenience?
Converting between expression body and block body is somewhat tedious and something you might want to do fairly often. Which is why I think VS offers it as a refactoring, it isn't a statement of one being better than the other.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With