Chapter 6: Working with Delegates, Events, and Exceptions Flashcards

1
Q

Event Syntax

A

<accessibility><strong>event &lt;</strong>delegate&gt; <eventname></eventname></accessibility>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you check for event subscribers?

A

if (eventHandler != null)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

The .net generic EvnetHandler delegate syntax.

A

public event EventHandler<ObjectEventArgs> eventName

This assumes that the first arguent will be the object publishing the event.

The second argument is the ObjectEventArgs EventArgs subclass to give more information to the handler

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Event Inheritance Quirk

A

Events can only be raised only from within the clas that declared it.

So best practice would have you create an OnEvent protected method to allow sub classes to call it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Try Catch

catch hierarchy

A

The catches will be executed top down, and only one will ever get executed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

The “finally” section…

A

Always executes

Always

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

SQL Exception property called “Class” fatal range?

A

20-25

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Exception.ToString() includes what?

A

The name of the exception class.

the Message property.

a stack trace

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

When creating your own Exception what should you make sure to do (best practice)

A

Make sure the Exception is [Serializable]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the three kinds of Exceptions?

A

Expression Lambdas

Statement Lambdas

and Async Lambdas

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are the two Built-in Delegate Types

A

Action

Func

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Where does the return type exist in Func declarations?

A

The last argument.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

The gist of anonymous methods

A

delegates defined inline.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly