Chapter 6: Working with Delegates, Events, and Exceptions Flashcards
Event Syntax
<accessibility><strong>event <</strong>delegate> <eventname></eventname></accessibility>
How do you check for event subscribers?
if (eventHandler != null)
The .net generic EvnetHandler delegate syntax.
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
Event Inheritance Quirk
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.
Try Catch
catch hierarchy
The catches will be executed top down, and only one will ever get executed.
The “finally” section…
Always executes
Always
SQL Exception property called “Class” fatal range?
20-25
Exception.ToString() includes what?
The name of the exception class.
the Message property.
a stack trace
When creating your own Exception what should you make sure to do (best practice)
Make sure the Exception is [Serializable]
What are the three kinds of Exceptions?
Expression Lambdas
Statement Lambdas
and Async Lambdas
What are the two Built-in Delegate Types
Action
Func
Where does the return type exist in Func declarations?
The last argument.
The gist of anonymous methods
delegates defined inline.