23.2. Syntax of user-defined conversion method declarations

As with operator overloading, you use the operator keyword to declare the conversion method. The full syntax for the declaration of the conversion method is:

public static <explicit|explicit> operator conv_type_out (conv_type_in operand)

Additional notes

  • Besides classes, you can also write conversion methods for structs (see Chapter 26).

  • The conversion method must be static.

  • The conversion method must either return the type for which the conversion is defined, or take that type in as one of the method parameters.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.250.53