在C#中添加数字 [英] Add numbers in c#
本文介绍了在C#中添加数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个数字文本框,需要将其值添加到另一个已经尝试过此代码的数字
i have a numerical textbox which I need to add it's value to another number I have tried this code
String add = (mytextbox.Text + 2)
,但是将数字2作为另一个字符添加如果我的文本框的值为13,则结果将变为132
but it add the number two as another character like if the value of my text box is 13 the result will become 132
推荐答案
String add = (Convert.ToInt32(mytextbox.Text) + 2).ToString();
您需要将文本转换为整数才能进行计算。
You need to convert the text to an integer to do the calculation.
这篇关于在C#中添加数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文