Locked lesson.
About this lesson
Once you've created a method, you may want to pass Parameters to those Methods to perform specific operations.
Exercise files
Download this lesson’s related exercise files.
28 - Passing Parameters To Methods.docx61.1 KB 28 - Passing Parameters To Methods SOLUTION.docx
58.8 KB
Quick reference
Passing Parameters To Methods
You can pass parameters to your methods.
When to use
Use this whenever you need to pass a parameter to a method.
Instructions
{
int a, b
a = 3;
b = 2;
Addthings(a,b);
}
static void Addthings(int x, int y)
{
int result;
result = x + y;
Console.WriteLine($"{x} + {y} = {result}");
}
Hints & tips
- Be sure to define the data type when you pass parameters to a method.
Lesson notes are only available for subscribers.