decimal AddPercent(decimal x, double percent) { return x * (1.0 + percent / 100.0); }a compile-time error occurs because a decimal cannot be multiplied by a double. The error is resolved by explicitly converting the second operand to decimal, as follows:
decimal AddPercent(decimal x, double percent) { return x * (decimal)(1.0 + percent / 100.0); }end example] End of informative text.
| |
Jagger Software Ltd | |
Company # 4070126 | |
VAT # 762 5213 42 |