示例#1
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                listBox1.Items.Clear();
                if (collection == null || collection.Count == 0)
                {
                    MessageBox.Show("Введите число");
                }
                else
                {
                    Salaries col = new Salaries();
                    collection.Sort();
                    foreach (Salaries s in collection)
                    {
                        listBox1.Items.Add(s.person + " , " + s.salary);
                    }
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show("Ошибка" + ex.Message);
            }
        }
示例#2
0
        private void button3_Click(object sender, EventArgs e)
        {
            listBox1.Items.Clear();
            int count;

            if (textBox1.Text == "" || (count = Convert.ToInt32(textBox1.Text)) == 0)
            {
                MessageBox.Show("Введите число");
                this.collection = null;
            }
            else
            {
                collection = new List <Salaries>(count);
                Salaries col;
                for (int i = 0; i < count; i++)
                {
                    col = new Salaries();
                    collection.Add(col);
                }
                foreach (Salaries s in collection)
                {
                    listBox1.Items.Add(s.person + " , " + s.salary);
                }
            }
        }