Locked lesson.
About this lesson
In this lesson, we introduce Methods and how to use them in your program.
Exercise files
Download this lesson’s related exercise files.
27 - Methods.docx61.1 KB 27 - Methods SOLUTION.docx
58.5 KB
Quick reference
Methods
Methods are programs within your program.
When to use
Use them to break apart parts of your code that you plan to use over and over again.
Instructions
{
int a, b, result;
a = 3;
b = 2;
result = a + b;
Console.WriteLine($"{a} + {b} = {result}");
DisplayMessage();
}
static void DisplayMessage()
{
Console.WriteLine("Program Ended");
}
Hints & tips
- Methods only run when they are called
Lesson notes are only available for subscribers.