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

Runtime cost of dynamic type resolution 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 dynamic variable.

C Sharp (C#)
dynamic value = [1];
Drag options to blanks, or click blank then click option'
Anull
B"text"
Ctrue
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around 10 makes it a string, not an integer.
2fill in blank
medium

Complete the code to access the length property on a dynamic variable.

C Sharp (C#)
dynamic obj = "hello";
int length = obj.[1];
Drag options to blanks, or click blank then click option'
ALength
Blength
CCount
DGetLength
Attempts:
3 left
💡 Hint
Common Mistakes
Using Count is for collections, not strings.
3fill in blank
hard

Fix the error in the dynamic method call.

C Sharp (C#)
dynamic obj = 123;
string text = obj.[1]();
Drag options to blanks, or click blank then click option'
AtoString
BToString
CConvert
DParse
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'toString' causes a runtime error.
4fill in blank
hard

Fill both blanks to create a dictionary with dynamic keys and values.

C Sharp (C#)
var dict = new Dictionary<[1], [2]>();
Drag options to blanks, or click blank then click option'
Adynamic
Bstring
Cint
Dobject
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing static types like string or int causes type errors.
5fill in blank
hard

Fill all three blanks to create a dynamic method call with runtime type resolution.

C Sharp (C#)
dynamic obj = GetDynamicObject();
var result = obj.[1]([2]: [3]);
Drag options to blanks, or click blank then click option'
ACalculate
Bvalue
C42
DExecute
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong method names or parameter names causes runtime errors.