Skip to content

Instantly share code, notes, and snippets.

@christiannagel
Created May 5, 2018 21:55
Show Gist options
  • Save christiannagel/46696874bd45d8f72ac243a4ca72aff7 to your computer and use it in GitHub Desktop.
Save christiannagel/46696874bd45d8f72ac243a4ca72aff7 to your computer and use it in GitHub Desktop.
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