0
Where does return; in C# Methods safe the value?
I am currently learning about Methods in C# and I have one issue. If I return a value, let's say, and integer, where is it safed? Does the Method itself contain the return value so I can use it? For example: public static void Main(string[] args) { int number1=Convert.ToInt32(Console.ReadLine()); int number2=Convert.ToInt32(Console.ReadLine()); Console.WriteLine(Sum(number1,number2)); Console.ReadLine(); } static int Sum(int number1, int number2) { return number1+number2; } Where is the return value stored? Can I call it later on? EDIT: Is it a thing that the value isn't even safed? Just thought about that...
2 Answers
0
it is not stored, the value is just put in where you put it.
if you want to store it you need to use a variable
example:
int a=Sum(number1,number2);
0
Ok thanks a lot.