看起来你可以使用:
decimal x = decimal.Parse(text.Substring(0, 7) + "." +
text.Substring(7),
CultureInfo.InvariantCulture);
Run Code Online (Sandbox Code Playgroud)
这实际上会将其解析为82.7700000,因为decimal保留了尾随零(在某种程度上),但也许这足够好了?不,你可以改变第二个参数
text.Substring(7).TrimEnd('0')
Run Code Online (Sandbox Code Playgroud)
请注意,我强烈建议您至少考虑使用decimal而不是double.你没有解释这个值代表什么,但如果它存储为你需要保留的十进制数字,它对decimal我来说更像是一种气味.
| 归档时间: |
|
| 查看次数: |
295 次 |
| 最近记录: |