← C# from Scratch Lesson 22 of 39 · 5 XP

Warm-up: the Twice method warm-up

Theory and problem statement

Machine translation, not yet reviewed by a native speaker.

A method is a piece of code with a name. The result type goes before the name, and return gives back the answer:

static int PlusOne(int x)
{
    return x + 1;
}

Console.WriteLine(PlusOne(4));   // 5

Task. Finish the method Twice(int x) that returns the number doubled. The program already reads the number and prints Twice(n).

Sign up for free to solve this task right in your browser: code editor, running, test checks and hints.