Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a list of integers.
C Sharp (C#)
List<int> numbers = new List<int>[1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using square brackets [] instead of parentheses.
Using curly braces {} which are for collection initializers.
✗ Incorrect
In C#, to create a new list, you use parentheses () after the constructor name.
2fill in blank
mediumComplete the code to add an element to the list.
C Sharp (C#)
numbers.[1](5);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
Append which is not a method on List.Using
Push which is used in stacks.✗ Incorrect
The Add method is used to add an element to a List in C#.
3fill in blank
hardFix the error in the code to check if the list contains the number 10.
C Sharp (C#)
bool hasTen = numbers.[1](10);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
Has which is not a List method.Using
Includes which is from JavaScript.✗ Incorrect
The Contains method checks if a list has a specific element.
4fill in blank
hardFill both blanks to create a dictionary and add a key-value pair.
C Sharp (C#)
Dictionary<string, int> ages = new Dictionary<string, int>[1]; ages.[2]("Alice", 30);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using curly braces {} to create the dictionary without initial values.
Using
Insert which is not a Dictionary method.✗ Incorrect
Use parentheses () to create the dictionary and Add to add a key-value pair.
5fill in blank
hardFill all three blanks to create a list, add an element, and check its count.
C Sharp (C#)
List<string> fruits = new List<string>[1]; fruits.[2]("Apple"); int count = fruits.[3];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
Length which is for arrays, not lists.Forgetting parentheses when creating the list.
✗ Incorrect
Create the list with (), add with Add, and get the number of items with Count.