>Hi,
>Given:
public class A {}
>public class B
>{
> public static implicit operator B(A a) { return new B(); }
> public static implicit operator C(B b) { return new C(); }
>}
>public class C {}
Would you find a statement like this too opaque:
C c = (B)new A();
Clear as mud to me Viv <g>
This advice seems the most important:
http://msdn.microsoft.com/en-us/library/z5z9kes2%28v=vs.71%29.aspx"By eliminating unnecessary casts, implicit conversions can improve source code readability. However, because implicit conversions can occur without the programmer's specifying them, care must be taken to prevent unpleasant surprises. In general, implicit conversion operators should never throw exceptions and never lose information so that they can be used safely without the programmer's awareness. If a conversion operator cannot meet those criteria, it should be marked explicit."
Once you replace ABC with more descriptive names, I think it will be fine as far as clarity is concerned.
double d = (int)((byte) 32);
although, why I didn't just do
double d = 32;
is beyond me. <g> The descriptive class names do however make it clear what I'm doing.