Simple way to convert integer to an array?

Posted on 2012-08-15
Last Modified: 2012-08-15
Please provide code in C#.

Given string "2349847"

How do I convert that to an array of integers, such that:

a[0] = 2
a[1] = 3
a[2] = 4
a[3] = 9
a[4] = 8
a[5] = 4
a[6] = 7
Question by:knowlton
    LVL 4

    Assisted Solution

    LVL 13

    Accepted Solution

    I don't know if there's a specific function for that, but if not you can always create the array and loop through every position of the string (with a for or while loop). Inside your loop you will capture one character (with myString.SubString) and assign it to the array.

    Dirty, but if you don't find a function that does that in one shot I guess it could work.
    LVL 5

    Author Closing Comment

    Thanks...this got me going in the right direction!

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
    Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
    This video discusses moving either the default database or any database to a new volume.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now