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

Generic class declaration 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 declare a generic class named Box.

C Sharp (C#)
public class Box[1] { }
Drag options to blanks, or click blank then click option'
A<T>
B[T]
C(T)
D{T}
Attempts:
3 left
💡 Hint
Common Mistakes
Using square brackets or parentheses instead of angle brackets.
Forgetting to include the generic type parameter.
2fill in blank
medium

Complete the code to declare a generic class named Pair with two type parameters.

C Sharp (C#)
public class Pair[1] { }
Drag options to blanks, or click blank then click option'
A(T, U)
B<T>
C<T, U>
D[T, U]
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses or square brackets instead of angle brackets.
Declaring only one type parameter when two are needed.
3fill in blank
hard

Fix the error in the generic class declaration syntax.

C Sharp (C#)
public class Container[1] { }
Drag options to blanks, or click blank then click option'
A[T]
B<T>
C(T)
D{T}
Attempts:
3 left
💡 Hint
Common Mistakes
Using square brackets or parentheses instead of angle brackets.
Omitting the generic type parameter brackets.
4fill in blank
hard

Fill both blanks to declare a generic class named Result with one type parameter and a property of that type.

C Sharp (C#)
public class Result[1] {
    public [2] Value { get; set; }
}
Drag options to blanks, or click blank then click option'
A<T>
BT
Cint
Dstring
Attempts:
3 left
💡 Hint
Common Mistakes
Using a concrete type like int or string instead of the generic type parameter.
Forgetting to declare the generic type parameter in the class.
5fill in blank
hard

Fill all three blanks to declare a generic class named Pair with two type parameters and two properties of those types.

C Sharp (C#)
public class Pair[1] {
    public [2] First { get; set; }
    public [3] Second { get; set; }
}
Drag options to blanks, or click blank then click option'
A<T, U>
BT
CU
Dint
Attempts:
3 left
💡 Hint
Common Mistakes
Using concrete types instead of generic type parameters for properties.
Forgetting to declare both generic type parameters.