Home > Net > Help everybody look at me what's wrong with this code, run not to come out.
Help everybody look at me what's wrong with this code, run not to come out.
Time:09-25
In VS, I want a result, the input character, if it is digital, to join the array, if it is a direct return, output "input is empty", if it is other characters, output "illegal characters enter again", but now as a result, the input character, carriage returns, in the input character to normal cycle, just learning c # can't also see have what problem, please help using System; Using System. Collections. Generic; Using System. Linq; Using System. The Text; Using System. The Threading. The Tasks;
The namespace firstSubject { Class Program { The static public bool buy (string num) { Try { The Convert. ToInt32 (num); return true; } Catch { return false; }; } The static void Main (string [] args) { Int [] ArrayList=new int [10]. int i, j; int sum=0; For (I=0; i <10; I++) { Console. WriteLine (" please input array ArrayList first {0} element value: ", I); String myString=Console. ReadLine (); If (buy (Console. ReadLine ())) { ArrayList. [I]=the Convert ToInt32 (myString); } Else if (myString. Length==0) { Console. WriteLine (" do not enter an empty string, please enter again. "); I -; } The else { Console. WriteLine (" illegal input, please input again. "); I -; }; } For (j=0; J & lt; 10; J++) { Sum=sum + ArrayList [j]; } Double business=sum/10; Console. WriteLine (" array ArrayList average is: {0: F4} : ", business); Console.ReadKey(); } } }
Please help to run, solve, thank you
CodePudding user response:
Remove one of the, String myString= the Console. ReadLine () ; If (buy ( Console. ReadLine ())) { ArrayList. [I]=the Convert ToInt32 (myString); }