Operator overloading in C# - How to overload "Default()" operator? - TechRepublic
Question
June 30, 2008 at 11:56 AM
srikkanthan

Operator overloading in C# – How to overload “Default()” operator?

by srikkanthan . Updated 18 years, 1 month ago

I have a class that generates reference numbers for a product. For some business logic scenario, I need to return a default reference number.

This class is used just like a data type. So I am overloading operators such as boolean comparison etc.

I found the default operator interesting. In numeric types it returns the default value. In reference types it returns null. How do I overload this to return a custom default value of my own?

This discussion is locked

All Comments