0
0
C Sharp (C#)programming~5 mins

List methods (Add, Remove, Find, Sort) in C Sharp (C#) - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
AThe List is cleared
BNothing happens, List stays the same
CAll items are removed
DAn error is thrown
Which method adds an item to the end of a List?
AFind
BSort
CAdd
DRemove
What does Sort do to a List?
AArranges items in order
BDeletes all items
CFinds an item
DAdds a new item
How does Find decide which item to return?
AReturns the last item
BReturns all items
CReturns a random item
DReturns the first item matching a condition
Which of these is a correct way to use Find with a lambda?
Alist.Find(x => x == 5)
Blist.Find(5)
Clist.Find()
Dlist.Find(x)
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.