Check the code bellow:
class Money
{
public Money(decimal amount)
{
Amount = amount;
}
public decimal Amount { get; set; }
public static implicit operator decimal(Money money)
{
return money.Amount;
}
public static explicit operator int(Money money)
{
return (int)money.Amount;
}
}
I don't understand how it would be useful in my code, couldn't I just do a method like:
public static int returnIntValueFrom(Money money)
{
return (int)money.Amount;
}
Wouldn't it be easier and clearer to implement?