c# - An object reference is required for the non-static field or method or property -
this question has answer here:
i trying action<t,t> delegate , got following error:
an object reference required non-static field, method, or property
the event declaration looks follows:
public event action<string, string> filestateprocess; and usage should looks this:
if (filestateprocess != null) { filestateprocess(file.fullname, temppath); } what doing wrong?
from declaration can see filestateprocess action non-static, assume method calling static method. in case, remove static keyword method , should good.
alternatively, can make filestateprocess static, mean value held in actual type, rather in object instance.
public static event action<string, string> filestateprocess; for more info, see:
static classes , static class members (c# programming guide).
Comments
Post a Comment