title: Why/when is it important to specify an operator as explicit?
body: <p>I've borrowed the code below from <a href="https://stackoverflow.com/a/7305947/93394">another question</a> (slightly modified), to use in my code: </p>
  
  <pre><code>internal class PositiveDouble 
  {
        private double _value;
        public PositiveDouble(double val) 
        {
            if (val &lt; 0)
                throw new ArgumentOutOfRangeException("Value needs to be positive");
            _value = val;
        }
  
        // This conversion is safe, we can make it implicit
        public static implicit operator double(PositiveDouble d)
        {
            return d._value;
        }
        // This conversion is not always safe, so we're supposed to make it explicit
        public static explicit operator PositiveDouble(double d)
        {
            return new PositiveDouble(d); // this constructor might throw exception
        }
  }
  </code></pre>
  
  <p>The original author of this code correctly adheres to the warnings given in MSDN's <a href="http://msdn.microsoft.com/en-us/library/z5z9kes2.aspx" rel="nofollow noreferrer">implicit</a> &amp; <a href="http://msdn.microsoft.com/en-us/library/xhbhezf4.aspx" rel="nofollow noreferrer">explicit</a> documentation, but here's my question: <strong>Is <code>explicit</code> always necessary in potentially exceptional code?</strong> </p>
  
  <p>So, I've got some types in my code (e.g. "Volume") that derive from PositiveDouble and I'd like to be able to set instances conveniently like the first line below:</p>
  
  <pre><code>Volume v = 10; //only allowed by implicit conversion
  Volume v = new Volume(10)  //required by explicit conversion, but gets messy quick
  </code></pre>
  
  <p>Being forced to use explicit casts everywhere makes the code much less readable. How does it protects the user? In the semantics of my program, I never expect a Volume to be negative; indeed, if it ever happens I expect an exception to be thrown. So if I use an implicit conversion and it throws, what "unexpected results" might clobber me?</p>