Basically, XNamespace provides an operator that performs an implicit conversion.
I believe that the rules of most common sense apply, use it only where it makes sense, and avoid confusion. The biggest problem is the unintended implicit conversion, which could potentially open up for programming errors. You can avoid this and still provide the conversion with an explicit conversion operator.
An example of a case where you want to use the explicit conversion operator instead of the implicit will be an entire class that allows conversion from a floating-point type; an implicit conversion will hide the truncation / rounding that would have happened, and thus make the user very confused (and probably be a source of errors.)
In my code, I used it several times, for example, in a very simple structure of check results, which provided implicit conversion to bool (but not from). This allowed me to do if (result) { ... } (the jury still does not know the benefits of this :)).
Guess that most of its use is used for "simple" data types, such as large integers, decimal numbers, etc.
Skurmedel
source share