CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2012
    Posts
    1

    Taking input from user and storing in an integer array

    Hello

    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

    Thanks

  2. #2
    Join Date
    Jul 2012
    Posts
    90

    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 05:24 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured