Int. J the parse (), and the convert toint32 () will be wrong, when the same in the console program code without exception, could you tell me why?
[code
Private void button1_Click (object sender, EventArgs e)
{
If (txt1. Text. The Trim ()!="")
{
String STR=txt1. Text;//input ten Numbers, commas between
String [] STRS=STR. The Split (', ');
Int [] array=new int [STRS. Length];
for (int i=0; i
Array [I]=the Convert. ToInt32 (STRS [I]);//is it always prompt the unusual
}
Txt2. Text=array [0]. ToString ();
}
} [/code]
CodePudding user response:
,2,3,4,5,6,7,8,9,11 string atxt="1";
Int [] aaa=atxt. The Trim (). The Split (', '). The Select (a=& gt; Int. Parse (a)). ToArray ();
Atxt=aaa [0]. ToString ();
CodePudding user response:
Do you want to see you is to control the contents of the equivalent int, you input can be converted to type int losing, 1, 1 May, for example, you enter 1, a is no good, cannot be converted into a plastic onlyCodePudding user response:
May be entered in Chinese comma, and segmentation is used in English, a breakpoint, debugging see split after the contents of the array;CodePudding user response:
Your debuggedString [] STRS=STR. The Split (', ', ', ');
May be you have a problem here
CodePudding user response:
Sleep