Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

104-P-01: Delegates and lambdas

Total questions: 10

Worksheet time: 14mins

Name
Class
Date
1.

Delegates, what is it?

2 lines
2.

Lambdas, what is it?

2 lines
3.

What types of delegates are pre-defined in C#?

a)

Actions

b)

Predicates

c)

Comparisons

d)

Functions

4.

How to create a lambda that takes 2 arguments?

a)

(x, y) -> x + y

b)

(x, y) => x + y

c)

(x, y) => { x + y; }

d)

(x, y) => { return x + y; }

5.

Select the correct information about this `Func` delegate

a)

It returns a char

b)

It returns an int

c)

It returns nothing

d)

It returns a tuple (int, double, string, char)

6.

Select the correct information about this `Func` delegate

a)

It takes 3 parameters

b)

It takes 4 parameters

c)

It takes 0 parameter

d)

It takes only a tuple as parameter

7.

Are ACDC greater, lower or equal to YAKA?

a)

Greater

b)

Lower

c)

Equal

8.

Does this code compile?

a)

YES!

b)

NO!

9.

Declare a delegate named `MyAwsomeDelegate` that takes an `int` and a `double` and returns nothing.

4 lines
10.

How many parameters can have a `Func`, at most?

a)

16, because why not? 🤔

b)

There is no limit, because nobody can limit our power! 😈

c)

5, it's already enough

d)

The answer D, always and forever

e)

6, for optimization reasons