+ 1
What exactly does return mean?
what does return mean in the terminology of computer science?
9 Respostas
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
0
I did mistake missing {} but cannot edit from phone.. sorry about that
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);
}
0
could have written private too in the MathDoSquare part.. I just wrote it this way this time
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.
- 1
what is the point of writing "public" in the first line?
- 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?
- 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?
- 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)