Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
throw expressions with C# 7
// C# 6
private readonly IBooksService _booksService;
public BookController(BooksService booksService)
{
if (booksService == null)
{
throw new ArgumentNullException(nameof(b));
}
_booksService = booksService;
}
// C# 7
private readonly IBooksService _booksService;
public BookController(BooksService booksService)
{
_booksService = booksService ?? throw new ArgumentNullException(nameof(b));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment