Key Concepts

Review core concepts you need to learn to master this subject

Return Keyword

static int ReturnAValue(int x) { // We return the result of computing x * 10 back to the caller. // Notice how we are returning an int, which matches the method's return type. return x * 10; } static void Main() { // We can use the returned value any way we want, such as storing it in a variable. int num = ReturnAValue(5); // Prints 50 to the console. Console.WriteLine(num); }

In C#, the return statement can be used to return a value from a method back to the method’s caller.

When return is invoked, the current method terminates and control is returned to where the method was originally called. The value that is returned by the method must match the method’s return type, which is specified in the method declaration.

Learn Python: Hello World
Lesson 1 of 1

What you'll create

Portfolio projects that showcase your new skills

Pro Logo