I guess I should expand on my [sort-of] gripe.  Implicit casting by the language itself is OK where it makes sense, like in your example of int and long.  But, logically, it can be confusing to use an implicit operator to convert between objects that have nothing in common, and never will (like Truck and Pear, for instance).

// David


Arild Fines wrote:
David La Motta wrote:
  
Thanks for the explanation.  I can see how the implicit operator can
be useful in the example you describe; still, I think it wasn't
necessary for C# to expose them to us.  I.e., let us deal with the
explicit casts and spare the confusion they may cause.  In other
words, an implicit cast from a Pear object to a Truck object can seem
quite odd, assuming their inheritance tree has nothing in common.
    

Sure, but would you really want to be required to use an explicit cast when
converting an int to a long?


--
Arild

AnkhSVN: http://ankhsvn.tigris.org
Blog: http://ankhsvn.com/blog
RSS: http://ankhsvn.com/blog/Rss.aspx

King Crimson lives in different bodies at different times and the
particular form which the group takes changes. When music appears,
which only King Crimson can play then, sooner or later, King Crimson
appears to play the music

  

Reply via email to