Q&A
Q1: | Is it possible to create custom events for an object? |
A1: | You can create custom events for objects created from your custom classes (see Hour 17, “Designing Objects with Classes”), but you cannot create custom events for existing C# objects such as forms and controls (without using some seriously advanced object-oriented techniques that are beyond the scope of this book). |
Q2: | Is it possible for objects that don't have an interface to support events? |
A2: | Yes. However, to use the events of such an object, the object variable must be dimensioned a special way or the events aren't available. This gets a little tricky and is beyond the scope of this book. If you have an object in code that supports events, look in Help for the keyword WithEvents ... |
Get Sams Teach Yourself C#™ in 24 Hours now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.