I'm triying to get the value of the selected item in a listbox which is in another class from the one from I'm trying to get the data.
What I do is the following:
Calling class:
Form1 form = new Form1();
var mail = form.getMail();
var pass = form.getPass();
Main class:
public string getMail() {
return this.listBoxMail.SelectedValue.ToString();
}
public string getPass()
{
return this.tb_pass.Text;
}
Always getting NullReferenceException. I ALREADY KNOW what this error means, what I need is to solve it. Any idea about how to achieve this? Thanks in advance.