Print Friendly and PDF
(Sorting Strings) Write an app that allows the user to enter strings in a TextBox. Each string input is added to a ListBox. As each string is added to the ListBox, ensure that the strings are in sorted order. [Note: Use property Sorted.]
(Sorting Strings) Write an app that allows the user to enter strings in a TextBox. Each string input is added to a ListBox. As each string is added to the ListBox, ensure that the strings are in sorted order. [Note: Use property Sorted.]


Sorting

Solution :

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Q33
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void listBox1_KeyDown(object sender, KeyEventArgs e)
        {
      

        }
        private void textBox1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                string b = textBox1.Text;
                char[] ab = b.ToCharArray();
                listBox1.Items.Add(b);
                listBox1.Sorted = true;
       
        }

        }
        private void button1_Click(object sender, EventArgs e)
        {

            MessageBox.Show("this is sorted Array");
        }
    }
}

zubairsaif

Zubair saif

A passionate writer who loves to write on new technology and programming

Post A Comment:

0 comments: