Argument Checking and Guard Clauses
suggest changePrefer
public class Order
{
public OrderLine AddOrderLine(OrderLine orderLine)
{
if (orderLine == null) throw new ArgumentNullException(nameof(orderLine));
...
}
}
Over
public class Order
{
public OrderLine AddOrderLine(OrderLine orderLine)
{
if (orderLine == null) throw new ArgumentNullException("orderLine");
...
}
}
Using the nameof
feature makes it easier to refactor method parameters.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents