What do people mean by caller in C#?
For example, concerning the bottom code: static method SumOfTwoNumber() returns a value to the caller. What exactly is the caller?
Is it referring to the line of code in which method SumOfTwoNumber() was invoked? Or is it referring to the type member, in this case static method Main(), in which SumOfTwoNumber() was invoked?
public class Foo
{
public static void Main()
{
int n1 = 7;
int n2 = 3;
int result = SumOfTwoNumbers(n1, n2);
}
public static int SumOfTwoNumbers(int num1, int num2)
{
return num1 num2;
}
}
CodePudding user response:
Both. The context of discussion will usually clarify which one is intended. The two different senses of "caller" are confirmed by official documentation. Infact both are actually implemented as caller info attributes in the system. Here are the relevant links in the official documentation for each:
