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 466023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:26:13+00:00 2026-05-12T23:26:13+00:00

I have a text box field inputs 123,145,125 I to separate this field into

  • 0

I have a text box field inputs 123,145,125 I to separate this field into an array of integers. And validate this field true or false if everything is parsed right.

CODE:

private bool chkID(out int[] val) 
{
    char[] delimiters = new char[] { ',' };
    string[] strSplit = iconeID.Text.Split(delimiters);  


    int[] intArr = null;
    foreach (string s in strSplit) //splits the new parsed characters 
    {
        int tmp;
        tmp = 0;
        if (Int32.TryParse(s, out tmp))
        {
            if (intArr == null)
            {
                intArr = new int[1];
            }
            else
            {
                Array.Resize(ref intArr, intArr.Length + 1);
            }
            intArr[intArr.Length - 1] = tmp;
        }

        if (Int32.TryParse(iconeID.Text, out tmp))
        {
            iconeID.BorderColor = Color.Empty;
            iconeID.BorderWidth = Unit.Empty;

            tmp = int.Parse(iconeID.Text);
            val = new int[1];
            val[0] = tmp;
            return true;
        }


    }
    val = null;
    ID.BorderColor = Color.Red;
    ID.BorderWidth = 2;
    return false;
}

//new Code:
private bool chkID(out int[] val) //bool satus for checkID function
{
string[] split = srtID.Text.Split(new char[1] {‘,’});
List numbers = new List();
int parsed;

        bool isOk = true;
        foreach( string n in split){
            if(Int32.TryParse( n , out parsed))
                numbers.Add(parsed);
            else
                isOk = false;
        }
        if (isOk){
            strID.BorderColor=Color.Empty;
            strID.BorderWidth=Unit.Empty;
            return true;
        } else{
            strID.BorderColor=Color.Red;
            strID.BorderWidth=2;
            return false;
        }
            return numbers.ToArray();
        }
  • 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-12T23:26:13+00:00Added an answer on May 12, 2026 at 11:26 pm

    The given function seems to do too much. Here’s one that answers the question implied by your title:

    //int[] x = SplitStringIntoInts("1,2,3, 4, 5");
    
    static int[] SplitStringIntoInts(string list)
    {
        string[] split = list.Split(new char[1] { ',' });
        List<int> numbers = new List<int>();
        int parsed;
    
        foreach (string n in split)
        {
            if (int.TryParse(n, out parsed))
                numbers.Add(parsed);
        }
    
        return numbers.ToArray();
    }
    

    EDIT (based on your comment on the question)

    You’ve defined the three things this function needs to do. Now you just need to create methods for each. Below are my guesses for how you could implement them.

    int[] ValidateIDs(int[] allIDs)
    {
        List<int> validIDs = new List<int>(allIDs);
    
        //remove invalid IDs
    
        return validIDs.ToArray();
    }
    
    void DownloadXmlData(int[] ids)
    {
        ...
    }
    

    Now you just execute your new functions:

    void CheckIconeID(string ids)
    {
        int[] allIDs = SplitStringIntoInts(ids);
        int[] validIDs = ValidateIDs(allIDs);
    
        DownloadXmlData(validIDs);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program in which the user inputs information into two separate text
I have a text input field like text box or text area. I want
I have one text box on that text box i am using required field
I have a text box in html form like this '&lt input id=yourinput type=text
I have a drop down box and some text input fields below it. Based
I have text box to enter a phone number. I'm using AJAX MaskedEditExtender and
I have text box in which your adds values in comma separated values. Once
i have form where i have text box value and link (add). when user
I have a text box which accepts time in the format HH:mm and entries
I have a text box with a certain width and a string. How do

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.