I would try something like this:-
List<double> doubles = new List<double>();
private void button1_Click(object sender, EventArgs e)
{
double result;
double.TryParse(textBox1.Text, out result);
if (result != null)
{
doubles.Add(result);
textBox1.Clear();
}
else
{
MessageBox.Show("Please enter valid number.");
}
}
Hope this helps
In reply to your comment, it is certainly possible to store any Class in a List<class>, something like this:-
class Car
{
public string Make { get; set; }
public string Model { get; set; }
}
List<Car> cars = new List<Car>();
cars.Add(new Car(){ Make = "Nissan", Model="Sunny"});
Here[
^] is the MSDN page for
List<t></t>
As for storing one List for both windows, the best thing would be to have a public property in your Main window which returns a
List<double></double>
and to pass this as a prameter to your second form. then you just add the second forms doubles directly to your List.