C# user input int to array

前端 未结 4 1392
难免孤独
难免孤独 2021-01-14 23:35

I\'m asking the user to input 5 numbers and store it into an array so I can send the values in a method and subtract 5 numbers from each array. When I use the:



        
4条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-15 00:05

    You just need to parse the string being entered from the console to int first.You accept int by doing:

    for(int i=0;i

    Just like @Furkle said, it is always best to use TryParse() which enables you to perform exception handling. MSDN has a nice tutorial on this.

提交回复
热议问题