加藤雅也,剩女带球跑,lenovo笔记本报价
在c#编程过程中,decimal.tryparse方法和decimal.parse方法都可以将字符串string转换为decimal类型,但两者还是有区别,最重要的区别在于decimal.tryparse方法在字符串无法转换为decimal类型的情况下不会引发程序异常,而decimal.parse方法则是直接抛出程序异常。decimal.tryparse方法在无法转换的情况下返回false,并且使用了out参数进行转换。
decimal.tryparse方法的签名为:static bool tryparse(string s, out decimal result)
decimal.parse方法的签名为:static decimal parse(string s)
使用decimal.tryparse方法进行类型转换的时候,decimal变量无需先行赋值,在调用decimal.tryparse方法后,将自动带出结果值。
备注:原文转载自博主个人站,原文链接为c#中decimal.tryparse方法和decimal.parse方法的异同之处_it技术小趣屋。
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Net Core Web Api项目与在NginX下发布的方法
asp.net core3.1 引用的元包dll版本兼容性问题解决方案
IdentityServer4实现.Net Core API接口权限认证(快速入门)
ASP.NET Core MVC通过IViewLocationExpander扩展视图搜索路径的实现
网友评论