Implicit Operator

As I was creating my Fraction class, I needed “an option” for automatic cast. Let’s see here what the problem was. When I want to represent an integer as a fraction, I have to do it like this:

But it is a little boring to type every time new Fraction(…). I wondered if there is a way when I type something like this

the integer to be automatically converted to a fraction. Well, for my happiness, there is such an option. The implicit keyword is used to declare an implicit user-defined type conversion operator. And here it is my usage.

Now, I can simply use Fraction f = 5; and I have a fraction object. Really cool!