计数数字循环基于c#中文本框值的设置 [英] count number loop based on set in textbox value in c#
问题描述
您好朋友,
我使用此代码来计算数字
int Startcount = Convert.ToInt32(TextBox1.Text);
int Endcount = Convert.ToInt32(TextBox2.Text);
int count = 0 ;
for ( int i = Startcount; i < 结束; i ++)
{
count = i;
}
label.Text = 数字: + count.ToString( );
textbox1中的值为0,而TextBox2的值为100000000000这个
i am gating error当我的TextBox2.text = 100000000000
i想要根据TextBox1中的设置来计算数字到TextBox2
请给我解决方案我该如何解决从TextBox1借给TextBox2的任何nuber
谢谢
你可以在Int32中保存的最大数字是:
2 , 147 , 483 , 647
所以你的价值:
< pre lang =c#> 100 , 000 , 000 , 000太大了!
将您的Convert.ToInt32
更改为Convert.ToInt64
调用,并使用长值我nstead of int。
Hello friend,
I am using this code to count number
int Startcount = Convert.ToInt32(TextBox1.Text);
int Endcount = Convert.ToInt32(TextBox2.Text);
int count = 0;
for (int i = Startcount; i < Endcount; i++)
{
count = i;
}
label.Text = "Number: " + count.ToString();
There is 0 value in textbox1 and TextBox2 value is 100000000000 this
i am gating error when my TextBox2.text = 100000000000
i want to count number based on set in TextBox1 to TextBox2
please give me soluton how can i solve cont any nuber lent from TextBox1 to TextBox2
Thank you
The largest number you can hold in an Int32 is:
2,147,483,647So your value of:
100,000,000,000is way, way too big!
Change yourConvert.ToInt32
toConvert.ToInt64
calls instead, and use long values instead of int.
这篇关于计数数字循环基于c#中文本框值的设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!