Mega Code Archive

 
Categories / C# Tutorial / 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 ? - . =