Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 592419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:44:16+00:00 2026-05-13T15:44:16+00:00

I have a long string, and I’d like to loop through it and pull

  • 0

I have a long string, and I’d like to loop through it and pull out all the int values in order. This seems simple enough, but I can’t seem to figure it out.

string raw = "I am a string and I have some numbers 3 45 333 2 39 inside of me 1839 9303, and I'd like to get these numbers into 9 -10 00  9e09 into a string[] or something else";

int[] justNumbers = raw.?????

Using C# .NET 3.5 and have access to Regex and Linq if necessary. Thanks.

Final result would be a long list of ints. i.e.

List<int> numbers = new List<int>();

WHAT I ENDED UP USING (NOT THE MOST EFFICIENT, BUT WORKED)

#region mysolution
        numbers = new List<int>();
        foreach (char item in raw)
        {
            if (item.ToString() == "0")
            {
                numbers.Add(Convert.ToInt32(item.ToString()));
            }
            else if (item.ToString() == "1")
            {
                numbers.Add(Convert.ToInt32(item.ToString()));
            }
            else if (item.ToString() == "2")
            {
                numbers.Add(Convert.ToInt32(item.ToString()));
            }
            else if (item.ToString() == "3")
            {
                numbers.Add(Convert.ToInt32(item.ToString()));
            }
            else if (item.ToString() == "4")
            {
                numbers.Add(Convert.ToInt32(item.ToString()));
            }
            else if (item.ToString() == "5")
            {
                numbers.Add(Convert.ToInt32(item.ToString()));
            }
            else if (item.ToString() == "6")
            {
                numbers.Add(Convert.ToInt32(item.ToString()));
            }
            else if (item.ToString() == "7")
            {
                numbers.Add(Convert.ToInt32(item.ToString()));
            }
            else if (item.ToString() == "8")
            {
                numbers.Add(Convert.ToInt32(item.ToString()));
            }
            else if (item.ToString() == "9")
            {
                numbers.Add(Convert.ToInt32(item.ToString()));
            }
        }

        #endregion
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T15:44:16+00:00Added an answer on May 13, 2026 at 3:44 pm

    Something along the lines of: (untested)

    var items = raw.Split(' ');
    var integers = new List<int>();
    foreach(var i in items){
        int test = 0;
        if(int.TryParse(i, out test)){
            integers.add(test);
        }
    }
    

    EDIT:
    There is an overload of TryParse that takes as a parameter, among other things, a bitwise comparison of System.Globalization.NumberStyles. With this overload, you can specify what types of integer strings it can accept (AllowExponent is one of them), so I would imagine, having not tested this that 9e09 would work. 🙂

    Hope this helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 289k
  • Answers 289k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Did you try to deploy and run your maven WAR… May 13, 2026 at 5:38 pm
  • Editorial Team
    Editorial Team added an answer From a Geocoder object, you can call the getFromLocation(double, double,… May 13, 2026 at 5:38 pm
  • Editorial Team
    Editorial Team added an answer You can do either but not both - you need… May 13, 2026 at 5:38 pm

Related Questions

I have a long string and I need to find instances of '#!#'+some text+'#!#'
This is a C# problem. I have a big object in memory at a
I have a sql data source and I have a really long string of
Given two spans like this: <span>Click for info</span> <span style=display: none>Here is a big
I have a command line application that needs to support arguments of the following

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.