V
V
Vlad Sivolobov2020-11-11 20:37:52
C++ / C#
Vlad Sivolobov, 2020-11-11 20:37:52

When should you use interfaces?

I don't understand the situation at all when they should be used.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vasily Bannikov, 2020-11-11
@vladsivolobov

In those situations where you can have several classes with the same set of methods, but with different implementations.
For example, you can invent an ITextWriter interface that will have a WriteLine method.
You can come up with several implementations of such an interface - one will write to the console, and the other can add lines to some kind of array, and the third one will generally be sent to some kind of web service.

A
Alexander Ananiev, 2020-11-11
@SaNNy32

https://www.w3schools.com/cs/cs_interface.asp

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question