There are a few restrictions to conversion operators : Conversion Operator Overload : Operator Overload C# Examples


C# Examples » Operator Overload » Conversion Operator Overload »

 

There are a few restrictions to conversion operators






Either the target type or the source type of the conversion must be a class that you create.
You cannot redefine the conversion from double to int.
You cannot define a conversion to or from Object.
You cannot define both an implicit and an explicit conversion for the same source and target types.
You cannot define a conversion from a base class to a derived class.
You cannot define a conversion from or to an interface.

(Quote from C# The Complete Reference, Publisher: Osborne/McGraw-Hill, March 8, 2002,
Language: English ISBN-10: 0072134852 ISBN-13: 978-0072134858)

Here are the other operators that cannot be overloaded. 
&&
||
[]
()
new
is
sizeof
typeof
?
->
.
=




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Operator Overload
» Conversion Operator Overload