C# allows us to define Implicit and Explicit operators. Unlike casting Implicit and Explicit operators defines how C# should behave when encountering an equals sign.
Implicit operator execution can be invoked when assigning a variable or calling a method.
To use Explicit operator we should do the same as casting an object. It's similar to a cast an object.
To define a implicit/explicit we need to make use of "operator", "implicit" or "explicit" keywords.
The following example demonstrates the use of both operators.
The explicit conversion is similar to a cast operation. We make visible the type to which we will convert the object. The implicit operator is less visible and difficult to understand if you don’t know that it exists.
❤️ Enjoy this article?
Forward to a friend and let them know.