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

Recursive pattern matching 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 match a tuple with two integers using recursive pattern matching.

C Sharp (C#)
bool IsPairOfInts(object obj) => obj is ([1], int);
Drag options to blanks, or click blank then click option'
Aint
Bstring
Cdouble
Dbool
Attempts:
3 left
💡 Hint
Common Mistakes
Using string or other types instead of int.
2fill in blank
medium

Complete the code to recursively match a nested tuple with an integer and another tuple.

C Sharp (C#)
bool IsNestedPair(object obj) => obj is (int, (int, [1]));
Drag options to blanks, or click blank then click option'
Adouble
Bstring
Cbool
Dint
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect types like string or bool.
3fill in blank
hard

Fix the error in the recursive pattern matching to correctly match a tuple with a string and a nested tuple of two integers.

C Sharp (C#)
bool MatchPattern(object obj) => obj is ([1], (int, int));
Drag options to blanks, or click blank then click option'
Aint
Bstring
Cbool
Ddouble
Attempts:
3 left
💡 Hint
Common Mistakes
Using int instead of string for the first element.
4fill in blank
hard

Fill both blanks to match a tuple with a string and a nested tuple where the first element is an int and the second is a bool.

C Sharp (C#)
bool CheckTuple(object obj) => obj is ([1], ([2], bool));
Drag options to blanks, or click blank then click option'
Astring
Bint
Cbool
Ddouble
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the types or using incorrect types like double.
5fill in blank
hard

Fill all three blanks to match a tuple with a string, a nested tuple with an int and a nested tuple with a bool and a double.

C Sharp (C#)
bool ComplexMatch(object obj) => obj is ([1], ([2], ([3], double)));
Drag options to blanks, or click blank then click option'
Astring
Bint
Cbool
Ddouble
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up the order of types or using wrong types like double in the wrong place.