tags:

views:

29

answers:

1

Can you make a struct that behaves like one of the built-in classes where you can assign the value directly without calling a property?

ex:

RoundedDouble count;
count = 5;

Rather than using

RoundedDouble count;
count.Value = 5;
+10  A: 

You do this via the implicit keyword.

For example, in your case, you'd want something like:

public static implicit operator RoundedDouble(double value)
{
     return new RoundedDouble(value);
}
Reed Copsey
This is perfect! Thanks!
Jonn
+1 Learn something new every day
Steve Ellinger