What are some advantages to using an interface in C#?

后端 未结 10 1230
小鲜肉
小鲜肉 2020-12-04 18:16

I was forced into a software project at work a few years ago, and was forced to learn C# quickly. My programming background is weak (Classic ASP).

I\'ve learned qui

10条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-04 18:49

    Here is a book that talks all about interfaces. It promotes the notion that interfaces belong to the client, that is to say the caller. It's a nice notion. If you only need the thing that you're calling to implement - say - count() and get(), then you can define such an interface and let classes implement those functions. Some classes will have many other functions, but you're only interested in those two - so you need to know less about the classes you're working with. As long as they satisfy the contract, you can use them.

提交回复
热议问题