×

c# · level 1 · unit 7 · lesson 1

  1. meet it
  2. guess first
  3. your turn
  4. fix it
  5. nailed it

Tap a green word if you get lost.

meet it

A is a recipe card with a name on top.

You have used commands like Console.WriteLine. Now make your own. A function is a set of instructions under one name. Write the recipe once, then use it as often as you like.

To one, write , a name with a capital letter, empty brackets and a block. void means it does a job but hands nothing back. Put your functions below the main lines.

To it, write its name with brackets and a semicolon, like Cheer();. Every line in its block then runs, top to bottom. Call it twice and it runs twice.

using System;

Cheer();
Cheer();

void Cheer()
{
    Console.WriteLine("Go team!");
    Console.WriteLine("You can do it!");
}

C# reads the whole file before it runs, so a call can come before the function it uses.