Possible Duplicate:
Why can't I use interface with explicit operator?
When I do this:
public struct Effect
{
public IEffect IEffect { get; private set; }
public Effect ( IEffect effect )
{
this.IEffect = effect;
}
public static implicit operator IEffect ( Effect effect )
{
return effect.IEffect;
}
public static explicit operator Effect ( IEffect effect )
{
return new Effect ( effect );
}
}
I get a compiler error like this:
'ImageEditor.Effect.implicit operator ImageEditor.IEffect(ImageEditor.Effect)': user-defined conversions to or from an interface are not allowed.
Why are they not allowed? Is this not a good practice?
This is detailed in section 10.10.3 of the C# language spec.
The summary reason of why though is ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With