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

Select clause projection 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 select the names from the list of people.

C Sharp (C#)
var names = people.Select(person => person.[1]);
Drag options to blanks, or click blank then click option'
ALength
BAge
CToString()
DName
Attempts:
3 left
💡 Hint
Common Mistakes
Using Age instead of Name will select numbers, not names.
Using ToString() may not return just the name.
2fill in blank
medium

Complete the code to select the ages from the list of people.

C Sharp (C#)
var ages = people.Select(person => person.[1]);
Drag options to blanks, or click blank then click option'
AAge
BName
CHeight
DWeight
Attempts:
3 left
💡 Hint
Common Mistakes
Selecting Name instead of Age will give names, not ages.
Selecting Height or Weight will give unrelated data.
3fill in blank
hard

Fix the error in the code to select the uppercase names.

C Sharp (C#)
var upperNames = people.Select(person => person.Name.[1]());
Drag options to blanks, or click blank then click option'
AToUpper
Btolower
Ctoupper
DUpperCase
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase method names like tolower or toupper causes errors.
UpperCase is not a valid method in C#.
4fill in blank
hard

Fill both blanks to select the first letter of each person's name and convert it to lowercase.

C Sharp (C#)
var firstLetters = people.Select(person => person.Name[1]0[2].ToString().ToLower());
Drag options to blanks, or click blank then click option'
A[
B]
C.
D()
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses instead of brackets causes errors.
Forgetting the closing bracket causes syntax errors.
5fill in blank
hard

Fill all three blanks to select a new object with uppercase name and age doubled.

C Sharp (C#)
var result = people.Select(person => new { Name = person.Name.[1](), Age = person.[2] * [3] });
Drag options to blanks, or click blank then click option'
AToUpper
BAge
C2
DName
Attempts:
3 left
💡 Hint
Common Mistakes
Using Name instead of Age for multiplication causes errors.
Forgetting parentheses after ToUpper causes errors.