Programming Examples

Are you a Programmer or Application Developer or a DBA? Take a cup of coffee, sit back and spend few minutes here :)

Tag Archive for ‘Implicit Operator Overloading’

Conversion Operator Overloading in C#

Fig 6. Using C# Overloaded Conversion Operators

Conversion Operator in C# converts one Type to another type. There are two flavours to it and we should implement both. One is Implicit Conversion and other one is Explicit Conversion. In a class type, we can provide two conversion operators those tells how a class can be casted to other type & how other type can be converted to class type. In this example, we will create a class called TimePart and add a conversion method to convert that to a String. We will also provide a conversion method which converts the String into a TimePart instance.

Continue Reading →