
Chapter 18 Working with C#
Delegate
You can design the following types of C# delegates:
- To create a delegate at the namespace level, create a class with the <<Delegate>> stereotype, and add an operation with the <<Delegate>> stereotype to this class and define a visibility for this operation. This visibility becomes the visibility of the delegate
{
public delegate int ActionOccurred();
}
- To create a delegate in a class, or structure, you just have to create an operation with the <<Delegate>> stereotype. In the following example, Class worker contains an internal delegate designed as an operation with the <<Delegate>> stereotype
{
public class Worker
{
public delegate WorkStarted();
}
}
Copyright (C) 2007. Sybase Inc. All rights reserved.
|
|