How one method can "call" another method, what is the name of it?
You are reading the code wrong. The correct one would be to affirm that the result of one method is executing another method.
This code snippet
Convert.ToDateTime("01/01/2016 00:00:00").ToShortDateString();
Can be converted as follows
DateTime date = Convert.ToDateTime("01/01/2016 00:00:00");
string stringDate = date.ToShortDateString();
What happens in the first example is that you are accessing a method that is available in the return of the previously executed method. As the return of the method ToDateTime
is a DateTime
, you have access to all available instance methods DateTime
.
DRT;
Just for information, something close to the quote "How one method can call another method" can be found more easily in javascript, where it is more common to find a function that returns another function. Still, the code is slightly different from the example quoted
function soma(arg1){
return function(arg2){
return arg1 + arg2;
}
}
soma(1)(2); //retorna 3
Como um método pode "chamar" outro método, qual o nome disso?
As stated in @Juliano’s reply is "call chain". In more specific cases it can also be calledbuild pattern
(building pattern)– Bruno Costa
Thank you to all who answered, if you could mark both answers. Thank you very much for your help.
– Robss70
Possible duplicate of What is Fluent Interface?
– Bacco
@Bacco, this question http://answall.com/questions/106955/o-que%C3%A9-Fluent-interface, does not answer my question, Julian’s answer is exactly what I would like to know. Thank you for your attention.
– Robss70
@Bacco, for a beginner like me, and perhaps for other beginners it is clearer the answer of Juliano than the explanation of what is Fluent Interface.
– Robss70
Agree @Robss70, it seems easier for min that I’m beginner understand the answer below than the Pattern design.
– Reis86