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

List methods (Add, Remove, Find, Sort) in C Sharp (C#) - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to add an item to the list.

C Sharp (C#)
List<string> fruits = new List<string>();
fruits.[1]("Apple");
Drag options to blanks, or click blank then click option'
ARemove
BAdd
CFind
DSort
Attempts:
3 left
💡 Hint
Common Mistakes
Using Remove instead of Add will try to delete an item.
Using Find or Sort will not add items.
2fill in blank
medium

Complete the code to remove an item from the list.

C Sharp (C#)
List<int> numbers = new List<int> {1, 2, 3};
numbers.[1](2);
Drag options to blanks, or click blank then click option'
ARemove
BFind
CAdd
DSort
Attempts:
3 left
💡 Hint
Common Mistakes
Using Add will add an item instead of removing.
Using Find or Sort will not remove items.
3fill in blank
hard

Fix the error in the code to find an item in the list.

C Sharp (C#)
List<string> names = new List<string> {"Anna", "Bob", "Cara"};
string found = names.[1](name => name == "Bob");
Drag options to blanks, or click blank then click option'
AFind
BRemove
CAdd
DSort
Attempts:
3 left
💡 Hint
Common Mistakes
Using Add or Remove will not find items.
Using Sort will reorder the list, not find an item.
4fill in blank
hard

Fill both blanks to sort the list in ascending order and then remove the first item.

C Sharp (C#)
List<int> values = new List<int> {5, 3, 8};
values.[1]();
values.[2](values[0]);
Drag options to blanks, or click blank then click option'
ASort
BAdd
CRemove
DFind
Attempts:
3 left
💡 Hint
Common Mistakes
Using Add instead of Remove will add an item instead of deleting.
Using Find instead of Sort will not order the list.
5fill in blank
hard

Fill all three blanks to add a new item, find it, and then remove it from the list.

C Sharp (C#)
List<string> pets = new List<string> {"Cat", "Dog"};
pets.[1]("Bird");
string foundPet = pets.[2](p => p == "Bird");
pets.[3](foundPet);
Drag options to blanks, or click blank then click option'
AAdd
BFind
CRemove
DSort
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up the order of methods.
Using Sort instead of Find or Remove.