I am having trouble converting the text from a TextBox to Double. In Win Forms it was fairy simple to convert it using the ToDouble() method, however now in WPF I am having issues with this.
First of all in the Main Window I have an int declared to help Id-ing other controls, this int is incremented only when pressing a button in order to add extra controls. Also I have a double[] declared to pass information from textboxes.
This is the int and double declaration:
public partial class MainWindow : Window
{
int i = 0;
double[] Fi;
Now in the button pressed method I am trying to pass the information to the array from the textbox:
Fi[i] = double.Parse(textBox15.Text);
MessageBox.Show("" + Fi[i]);
This is the error message I get when debugging the code:
An unhandled exception of type 'System.NullReferenceException' occurred in WpfApplication2.exe
Additional information: Object reference not set to an instance of an object.
The textbox is not null since I am inputing value to it from the keyboard, in this stage i = 0. Any advise on this matter? It is the 3rd attempt to convert, I have also user so far:
Fi[i] = Convert.ToDouble(textBox15.Text);
also giving the same error.