Method output - return - code clarification needed

Hi to all,
can anyone try to explain to me the logic order in code execution? I learned it “for granted” or let’s say blindly (hope you get my point), I could write the code again, but I don’t understand how does it work completely. I attached the screenshot pointing out to the confusion parts.
eg. How does the string planet get the “Jupiter” value? What is the circle order so the result is “..* Welcome to Jupiter ..*”

If it’s hard to explain here in the text, please paste any link to a good explanation to similar operations. I’m uncomfortable moving forward with practice until completely understand how this works.

Thank you in advance. :slight_smile:

using System;
namespace Return
class Program
static void Main(string args)
static string DecoratePlanet(string planet)
return $"..* Welcome to {planet} ..*";

Hey there,

On this line:


You basically tell the program to output something to the console on the right.

That output is the returned string from the method declared under, named DecoratePlanet.

Methods can often take input. The input, in this case, is the string "Jupiter".

DecoratePlanet(string planet) is a method, that takes one string parameter. This parameter is planet. It’s a placeholder. It will wait to receive a value.

That value is "Jupiter", as mentioned above. “Jupiter” is the argument, or input, that will come in place of the parameter, or placeholder mentioned above.

Your method DecoratePlanet() comes after the Main() method. Which might be why you’re confused.

It doesn’t matter that it comes after. This method will return its content once it is called.

And it is in fact called on this line: Console.WriteLine(DecoratePlanet(“Jupiter”));

When the method is called, it places the input “Jupiter” in place of {planet} on the line return $" *.* .* Welcome to {planet} *.* .*";.

And the full string is then printed to the console.


DecoratePlanet(string planet) // <--- planet is a placeholder, waiting to receive input.

We provide DecoratePlanet with the input “Jupiter”, in place of planet.

return $"*_*_* Welcome to {planet} *_*_*"; // <--- "Jupiter" is placed in the string, in place of {planet}.

The output appears in the console once the method is called, and printed to the console.


Thank you for the quick reply and time to explain this to me. I understand this way better now.

I guess that the place holder that waits for the input and the way how the whole code is set, is something that was confusing the most. Also, two times string mentioned in the same line of code:
static string DecoratePlanet(string planet)

Thank you!

1 Like

Just to be completely sure:

The first string means that you expect this method to return a string

return $"*_*_* Welcome to {planet} *_*_*";

The second string (string planet) means that your placeholder expects to receive a string


1 Like

I think I get it. See the order on screenshot. That’s why I was confused.

the order

I guess, I’ll just have to get used to this type of codes.