Can you give and example when should I send an interface to a Ctor?
Let say if I want to force a class to use a specific behavior?
Can you give and example when should I send an interface to a Ctor?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You pass an interface to a constructor for the same reasons you pass an interface to any method. For example, if your constructor takes a list of objects, you may accept an IList rather than a List. This is saying that the constructor accepts any option that looks and behaves like a list rather than requiring an actual list, making it more generic.