Skip to content

Instantly share code, notes, and snippets.

@Microsofttechies
Created March 27, 2015 20:18
Show Gist options
  • Select an option

  • Save Microsofttechies/7092cd736798e2c79f34 to your computer and use it in GitHub Desktop.

Select an option

Save Microsofttechies/7092cd736798e2c79f34 to your computer and use it in GitHub Desktop.
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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment