M
M
Mikhail32022-02-28 18:38:07
C++ / C#
Mikhail3, 2022-02-28 18:38:07

What is the purpose of specifying the return type of a class for a delegate and a function?

I don't understand how it works, why do we specify the return type of the class? Explain to the fool in simple terms, please, how it all works. 621cec0be0afc313739726.jpeg
PS - This is the 6th chapter of the metanit. Covariance and Contravariance

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vasily Bannikov, 2022-02-28
@vabka


why do we specify the return type of the class

Well, so that we can return a value with this type from the method.
Try not to specify, or specify the wrong one, and you will get a compilation error.

F
freeExec, 2022-02-28
@freeExec

To understand what kind of type they return to us, everything seems to be obvious. You do not just create EmailMessage there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question