I am currently working on a Windows Forms Application and I need to create a few methods in another class and then call the methods back into my form1.cs but every time I set my global variables equal to the ones I returned from the method, it says that my variables do not exist in the current context.
I'm still learning how to work with c sharp so it might not be any close to perfect but this is an example of what is happenning:
salesDifference is my global variable that i created in form1.cs
comp is the name of my class that i created at the top of form1.cs aswell
difference is the name of the variable that i returned in the method GetDifference but it says that difference does not exist in the current context and i don't know why >.<
Can someone help me fix this problem?
I'm still learning how to work with c sharp so it might not be any close to perfect but this is an example of what is happenning:
Code:
private void btnDifference_Click(object sender, EventArgs e)
{
lblDifference.Visible = true;
salesDifference = comp.GetDifference(difference);
outputMessage = "The difference between the highest and lowest sales is $" + salesDifference;
lblDifference.Text = outputMessage;
}
salesDifference is my global variable that i created in form1.cs
comp is the name of my class that i created at the top of form1.cs aswell
difference is the name of the variable that i returned in the method GetDifference but it says that difference does not exist in the current context and i don't know why >.<
Can someone help me fix this problem?
Comment