如何TryParse并返回没有任何变量的值 [英] How to TryParse and return the value without any variable
本文介绍了如何TryParse并返回没有任何变量的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想尝试修改变量并返回值而不存储它。
< pre lang =c#> memory = memory - Double .Parse(display.Text);
在上面的代码中,display.Text值直接解析而不存储
有没有办法在不使用任何变量的情况下TryParse上面的代码
解决方案
只需使用临时变量;请参阅 http://msdn.microsoft.com/en-us/library/ f02979c7(v = vs.110).aspx [ ^ ]。
不,没有办法避免out
被修改 TryParse()方法的变量。
为什么你关心它?
如果有很多这样的转换,你可以重复使用相同的double
变量。
I want to tryParse a variable and return the value without storing it.
memory = memory - Double.Parse(display.Text);
Here in the above code the display.Text value is directly parsed without being stored
Is there any way to TryParse the above code without using any variable
解决方案
Just use a temporary variable; see http://msdn.microsoft.com/en-us/library/f02979c7(v=vs.110).aspx[^].
No, there's no way to avoid theout
modified variable of a TryParse() method.
Why are you concerned about it?
If it's many such conversions one after another, you can re-use the samedouble
variable.
这篇关于如何TryParse并返回没有任何变量的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文