You can model C# overloaded operators as UML operations.
Before you begin
Before you perform this procedure, a UML model must be open
with the C# transformation profile applied.
About this task
To model overloaded operators:
Procedure
- Add a new operation to a class and name it as the desired
operator. For example, name the operation operator
!=.
- Define the operator using the following steps:
- Set the visibility of the operation to Public.
- Set the qualifiers of the operation to Static.
- Set the return type of the newly created operation to <Primitive
Type> Boolean.
- Add two parameters of the type containing class to the
newly created operation. For example, name the parameters c1 and c2.
Example
For example, you can overload the following two operators
in the context of a class, C1:
Equal (==)
Not equal (!=)
Figure 1. Class C1 in the diagram.
Figure 2. Properties set for UML operation operator !=.