Created
May 5, 2018 21:55
-
-
Save christiannagel/46696874bd45d8f72ac243a4ca72aff7 to your computer and use it in GitHub Desktop.
throw expressions with C# 7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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