Implementing User-Defined Casts实
2019-02-14 本文已影响0人
津涵
Currency.cs
![](https://img.haomeiwen.com/i16067886/1236c6e2826479f6.png)
Main.cs
![](https://img.haomeiwen.com/i16067886/add645b3f049e323.png)
Tips
(1)尽量不损失精度的高级用法:Convert.ToUInt16
The System.Convert object contains a large number of static methods to perform various numerical conversions, and the one that we want is Convert.ToUInt16. Note that the extra care taken by the System.Convert methods comes at a performance cost. You should use them only when necessary.
但会损失一些效率