Skip to content
Discussion options

You must be logged in to vote

With records you will be able to do this:

public record MyService(IServiceA serviceA, IServiceB serviceB, IServiceC serviceC) {
    // members go here
}

It's expected that primary constructors (the feature that allows for a parameter list to be specified after the type name) will be supported for normal classes by C# 10.0 complete with a constructor block where you can perform validation:

public class MyService(IServiceA serviceA, IServiceB serviceB, IServiceC serviceC) {
    public MyService {
        if (serviceA is null) throw new ArgumentNullException(...);
        if (serviceB is null) throw new ArgumentNullException(...);
    }

    // members go here
}

With #2145 you could possibly…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by ekisielinski
Comment options

You must be logged in to vote
1 reply
@Richiban
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants