❔ Lists

i am doing a course and the instructor wanted us to create a list that prints even numbers from 100 to 170.
his solution is below and it confuses me because I don't know why he put "public static List<int> Solution()" just to create another list later.
What's the need of the first list?

public class ListsExercise {


public static List<int> Solution() {
// TODO: write your solution here
//create a new list
List<int> myList = new List<int>();
//go thorugh every number beyweem 100 and 170
for (int i = 100; i <= 170; i++) {
//check if its an even number
if (i % 2 == 0) {
//add it to the list
myList.Add(i);
}
}
//return the list
return myList;
}

}
Was this page helpful?