Drill 16: Make it smaller — Methods and parameters
Write a smaller version of the example that keeps the core idea.
What you will be able to do
- Write a smaller version of the example that keeps the core idea.
Practice task
Write a smaller version of the example that keeps the core idea.
public class Lesson
{
public string Describe(string title, int minutes = 10)
{
return title + " takes " + minutes + " minutes";
}
public string Describe(string title)
{
return "No duration set for " + title;
}
public void Track(string title, out int slot, ref int seen)
{
slot = seen;
seen += 1;
}
}
var lesson = new Lesson();
var summary = lesson.Describe("C#", minutes: 12);
var shortSummary = lesson.Describe("HTML");
int slot;
var seen = 0;
lesson.Track("C#", out slot, ref seen);
Console.WriteLine(summary);
Console.WriteLine(slot);Your turn
EasyWrite your answer
Write a smaller version of the example that keeps the core idea.
TEXT · starter
Your answer…Study tools
Make it yours.
Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.
Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign inFinished reading?
Lock in what you just learned.
0%
Mark this lesson complete to save your place and move one step closer to the certificate.