Overloading = operator in C#

c#, operator-keyword, overloading

Solution

Yes, by creating an implicit type cast operator for `FixedPoint` if this class was written by you.

class FixedPoint
{
    public static implicit operator FixedPoint(double d)
    {
        return new FixedPoint(d);
    }
}

If it's not obvious to the reader/coder that a `double` can be converted to `FixedPoint`, you may also use an explicit type cast instead. You then have to write:

FixedPoint fp = (FixedPoint) 3.5;

Problem

OK, I know that it's impossible, but it was the best way to formulate the title of the question. The problem is, I'm trying to use my own custom class instead of float (for deterministic simulation) and I want to the syntax to be as close as possible. So, I certainly want to be able to write something like ``` FixedPoint myNumber = 0.5f; ``` Is it possible?

Original source