+ 1

What exactly does return mean?

what does return mean in the terminology of computer science?

2nd Aug 2016, 4:01 PM
Himansh Mulchandani
Himansh Mulchandani - avatar
9 Réponses
0
there is basicly two kind of method. one that is declared with void which means it does not return value and method that return value. Example: public int MathDoSquare(int x) { a= x*x; return a; } public static Main(args e) MathDoSquare(4); Console.Writeline(a); output: 16 (tell me if I did mistake in the code but the idea is this) hope it helps
2nd Aug 2016, 4:22 PM
Máté Lencsés
Máté Lencsés - avatar
0
I did mistake missing {} but cannot edit from phone.. sorry about that
2nd Aug 2016, 4:23 PM
Máté Lencsés
Máté Lencsés - avatar
0
You need to declare variable a in the MathDoSquare() method, i.e. write int a = ..... Also, variable a would not be visible in the Main() function (as it belongs to MathDoSquare only). You need to assign the returned value to another variable, eg int b = MathDoSquare(4); Console.WriteLine(b); so the code would look like: public int MathDoSquare(int x) { a = x * x; return a; } public static void Main() { int b = MathDoSquare(4); Console.WriteLine(b); }
2nd Aug 2016, 4:57 PM
Tomek Cymes
Tomek Cymes - avatar
0
could have written private too in the MathDoSquare part.. I just wrote it this way this time
2nd Aug 2016, 5:14 PM
Máté Lencsés
Máté Lencsés - avatar
0
These are the accessible keywords. Public-accessible within the program using references. private only accessible within the class. protected means accessible within the class and derived classes too. You should go through this application it explains this section.
2nd Aug 2016, 5:21 PM
Máté Lencsés
Máté Lencsés - avatar
- 1
what is the point of writing "public" in the first line?
2nd Aug 2016, 5:10 PM
Himansh Mulchandani
Himansh Mulchandani - avatar
- 1
ok then whats the point of writing private? i want to understand the meaning of each and every word written in the first few lines.. can anyone help please?
2nd Aug 2016, 5:18 PM
Himansh Mulchandani
Himansh Mulchandani - avatar
- 1
ok thanks! i just completed the first 2 modules and didnt understand the meaning of first line, maybe later it is explained.. can i become a good coder after i get the certificate of this app?
2nd Aug 2016, 5:30 PM
Himansh Mulchandani
Himansh Mulchandani - avatar
- 1
you will become a good coder if you go deep into programing spend your freetime on it. It help a lot to understand the basics. After that it is up to you. You can learn .NET class librarys you can use during coding. Or .UNET if you want to develop games. (it is a modified .NET for the unity3d engine)
2nd Aug 2016, 5:48 PM
Máté Lencsés
Máté Lencsés - avatar