Recall & Review
beginner
What does the
Add method do in a List?The
Add method adds a new item to the end of the List. Think of it like putting a new book at the end of a shelf.Click to reveal answer
beginner
How does the
Remove method work in a List?The
Remove method deletes the first occurrence of a specific item from the List. Imagine taking out the first matching book from your shelf.Click to reveal answer
intermediate
What is the purpose of the
Find method in a List?The
Find method searches the List and returns the first item that matches a condition you give. It's like looking for the first red apple in a basket.Click to reveal answer
beginner
What does the
Sort method do in a List?The
Sort method arranges the items in the List in order, usually from smallest to largest or alphabetically. Like organizing books by title on a shelf.Click to reveal answer
intermediate
How can you use a lambda expression with
Find in a List?You can pass a lambda expression to
Find to specify the condition for searching. For example, list.Find(x => x > 10) finds the first number greater than 10.Click to reveal answer
What happens when you call
Remove on a List with an item not present?✗ Incorrect
If the item is not found,
Remove does nothing and the List remains unchanged.Which method adds an item to the end of a List?
✗ Incorrect
Add appends a new item to the end of the List.What does
Sort do to a List?✗ Incorrect
Sort arranges the List items in ascending order.How does
Find decide which item to return?✗ Incorrect
Find returns the first item that matches the condition you provide.Which of these is a correct way to use
Find with a lambda?✗ Incorrect
You must provide a condition as a lambda expression, like
x => x == 5.Explain how you would add, remove, find, and sort items in a List in C#.
Think about how you manage a collection of things on a shelf.
You got /4 concepts.
Describe a real-life example that helps you remember what the List methods Add, Remove, Find, and Sort do.
Imagine managing books or fruits.
You got /4 concepts.