a pair of implicit and explicit conversion operator
Implicit keywords: user-defined type declarations for implicit conversion operator. It can be implemented two different types of implicit conversion code readability.
Explicit Keywords: declaration must be invoked by converting user-defined type conversion operator. Unlike implicit conversion.
1 public static implicit operator PaymentDTO(Payment payment) 2 3 { 4 5 return new PaymentDTO(){Name=payment.Name}; 6 7 }
use:
1 PaymentDto dto = new Payment(){Name="paypal"};