Created
December 23, 2014 17:23
-
-
Save mvirkkunen/f5f3927dbbb87a54941c to your computer and use it in GitHub Desktop.
Constructor injection in C# now vs. C# 6
This file contains hidden or 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# now | |
// Types mentioned 2 times, names mentioned 4 times | |
public class DerpController | |
{ | |
readonly ISomeService Some; | |
readonly IAnotherService Another; | |
public DerpController(ISomeService some, IAnotherService another) | |
{ | |
Some = some; | |
Another = another; | |
} | |
} | |
// C# 6 | |
// Types mentioned 2 times, names mentioned 3 times | |
public class DerpController6(ISomeService some, IAnotherService another) | |
{ | |
ISomeService Some { get; } = some; | |
IAnotherService Another { get; } = another; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment