So, I have a simple C# application. The application lets a user enter a test score, and click Add button. When clicked, the text box contents (if valid) should enter into the list object.
My current code is saying that it the object doesn't exist in the current context.
private void ScoreCalculatorApplication_Load(object sender, EventArgs e)
{
List<int> scoreList = new List<int>();
}
private void btn_Add_Click(object sender, EventArgs e)
{
scoreList.Add();//this line has the problem
}
So, I am not sure why the scoreList doesnt exist, because the ScoreCalculatorApplication_Load method executes on loading the app.
Anyway, I also considered something like this:
private void ScoreCalculatorApplication_Load(object sender, EventArgs e)
{
//remove this method.
}
private void btn_Add_Click(object sender, EventArgs e)
{
//is there a test to see if this object exists?
if (//see if the list does not exist)
//if not existant, create it here.
scoreList.Add();
}
So, The problem is I dont know how to test if the object exists.