Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have this windows application

enter image description here

1.- So, first when I Add a number it added to listbox1 but not to list 2. I need to be add ed to listo 2 to

2.- I need the numbers be added separately... For example if I add number 202, it split on 2 after 0 after 2

3.- I need add button for FIFO, but I don't know how can I program it.

4.-Finally compare one by one it with listbox1 with listbox2 with polindrome method, and if its palindrome show message box, say "they are polindrome", if not, say "number it's not palindrome.

  private void button1_Click(object sender, EventArgs e)
        {

        int newvalue;


        if (int.TryParse(textBox1.Text, out newvalue))

        {

            numeros.Add(newvalue);

            listBox1.Items.Add(textBox1.Text);


        }
        else
         MessageBox.Show("insert a number");



        textBox1.Clear();
        textBox1.Focus();

    }
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
508 views
Welcome To Ask or Share your Answers For Others

1 Answer

For dealing with this problem you should keep your main data in memory (List<int>) and manipulate them using different methods and show the result in the listboxes.

Separating your digits can be done this way :

        List<int> SeparateDigits(int n)
        {
            var result = new List<int>();
            while(n>0)
            {
                result.Add(n % 10);
                n /= 10;
            }
            return result;
        }

After calling this method you can add the list data to both your listboxes if it's what you want.
(sorry for being late)
Good luck.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...