Where does return; in C# Methods safe the value? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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...

12th Jan 2017, 12:34 PM
Eric
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);
12th Jan 2017, 12:43 PM
‫שי קמחי‬‎
‫שי קמחי‬‎ - avatar
0
Ok thanks a lot.
12th Jan 2017, 1:02 PM
Eric