Friday, 27 March 2015

An object reference is required for the nonstatic field, method, or property


It looks like you are calling a non static property from a static method. You will need to either make the property static, or create an instance of class
static void SetTextboxTextSafe(int result)
{
label1.Text = result.ToString();
}
or
private static void SumData(object state)
{
int result;
//int[] icount = (int[])state;
int icount = (int)state;
for (int i = icount; i > 0; i--)
{
result += i;
System.Threading.Thread.Sleep(1000);
}
MyClass objMyClass = new MyClass();
objMyClass.setTextboxText(result);
}
view raw gistfile1.cs hosted with ❤ by GitHub