Why can't I use interface with explicit operator?

Posted by theburningmonk on Stack Overflow See other posts from Stack Overflow or by theburningmonk
Published on 2010-03-12T14:05:16Z Indexed on 2010/03/12 14:07 UTC
Read the original article Hit count: 340

Filed under:
|
|
|

Hi,

I'm just wondering if anyone knows the reason why you are not allowed to use interfaces with the implicit or explicit operators?

E.g. this raises compile time error:

public static explicit operator MyPlayer(IPlayer player)
{
 ...
}

"user-defined conversions to or from an interface are not allowed"

Thanks,

© Stack Overflow or respective owner

Related posts about c#

Related posts about type-conversion