Argument Checking and Guard Clauses C# with Example



Argument Checking and Guard Clauses C# with Example

Prefer 
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. 

0 Comment's

Comment Form

Submit Comment