Prev | Current Page 176 | Next

Guy Fouch?©, Trey Nash

"Accelerated VB 2008"

This interface defines a contract, which states that any type that implements this interface
must implement the Paint method.
Since the classes ListBox and Button implement the interface, you can treat them both as
type IUIControl. You can store any instance of either Button or ListBox in a variable declared
as IUIControl. The references to objects of these class types are implicitly convertible to the
IUIControl type. However, to convert an IUIControl reference back into a ListBox or Button
reference requires an explicit conversion, and that coercion will fail if the object pointed to by
the IUIControl reference is not of the type specified by the conversion.
Finally, consider naming methods according to both the action they perform and where
the action is directed. For example, suppose the IUIControl.Paint method takes a Graphics
object as a parameter telling it where to paint itself. The code is more readable if the method is
named IUIControl.PaintSelfTo(). This way, the method call reads like a spoken language in
the sense that a method call that looks like control.PaintSelfTo(myGraphicsObject) is saying,
???control, please paint yourself to myGraphicsObject.???
Defining Interfaces
Interface declarations are similar to class declarations, but interfaces cannot declare fields,
and they can only declare, but cannot implement, other members.


Pages:
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
Jaki wybrać olej śmieszne dowcipy żetony do pokera praca w holandii dieta light