Now, in this section we’ll see that how to work with delegates which are returning values. Till now, we have seen that delegates are returning nothing, they are just as is processing the data that is getting passed in. so, let’s try to work with one which is returning some data. so, i’ll change the code a bit and then it will look like
so, in the different methods, you could see that i have modified the return statement by just adding the nos 1,2 and 3 in three different methods, just to differentiate between which method is getting returned. Now, when i run the program, it will produce the below output as shown below:
and the reason for this is quite simple, that even though we have multiple delegates in the invocation list and each one is returning different values individually, but in case of multicast delegate it will produce that value which will be returned in the last. Hence, it produced the last one as a result. In case i want each individual results so in that case i would need to call the delegates explicitly. so, with this i would like to wrap, till then stay tuned and happy coding.