Why you are Creating List object every time when you keypress event..
Initialize only once, so you can add numbers to the list.
List<int> lst = new List<int>();
and modify your events as,
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
int i = 0;
if (e.KeyChar == Convert.ToChar(Keys.Enter) && i < 10)
{
lst.Add(int.Parse(textBox1.Text));
textBox1.Text = "";
i++;
}
}
and
private void button1_Click(object sender, EventArgs e)
{
int[] array = lst.ToArray();
DoSort(array);
}
it's working now...
Hope it helps..