Ahjesus custom implicit conversion and display Conversion

Source: Internet
Author: User

The implicit keyword is used to declare an implicit user-defined type conversion operator.

If you can ensure that the conversion process does not cause data loss, you can use this keyword to perform implicit conversion between user-defined types and other types.

Reference timestamp this

 

The explicit keyword is used to declare the User-Defined type conversion operator that must be called using forced conversion.

Reference timestamp this

 

One thing to note is that an explicit or implicit statement cannot be written to a class at the same time, but only one of them can be written.

However, if an implicit conversion is declared, the corresponding display conversion is also automatically provided.

If Explicit conversions are declared, the corresponding implicit conversion is not provided.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.