Why can’t I define both implicit and explicit operators?

Check this: Why can’t coexist implicit and explicit operator of the same type in C#?

If you define an explicit operator, you will be able to do something like this:

Thing thing = (Thing)"value";

If you define an implicit operator, you can still do the above, but you can also take advantage of implicit conversion:

Thing thing = "value";

In short, explicit allows only explicit conversion, while implicit allows both explicit and implicit… hence the reason why you can only define one.

Leave a Comment