September 29th, 2012, 06:30 AM
Taking input from user and storing in an integer array
I am new to C# programming. I am developing an application and am stuck in a part of it. I want to take an input from the user(console mode) and the input would be a series of numbers like 25 40 84 52 15 21 45 or 25,40,45,57,23,44 . As I am taking the input from the user the numbers can be seprated by a space or a comma. I want to take these numbers and store it in an integer array. If anyone can guide me as to how this is done or maybe can point me to a relevant reference. I tried searching for this on internet but couldn't find much help
October 2nd, 2012, 06:22 AM
Re: Taking input from user and storing in an integer array
First, decide on a delimiter (the character that separates the values). Then use the string class' Split method to produce the array. This will produce an array of strings. Next loop through the array converting the values to integers and store them in a second array.
Last edited by CGKevin; October 2nd, 2012 at 06:24 AM.
Click Here to Expand Forum to Full Width