© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
5 replies
DustinMarino

❔ 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;
}

}
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Lists
C#CC# / help
3y ago
❔ Adjust lists
C#CC# / help
3y ago
❔ ✅ C# lists
C#CC# / help
3y ago
✅ EntityFrameworkCore lists
C#CC# / help
4y ago