c# - An object reference is required for the non-static field or method or property -


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

Popular posts from this blog

android - Pass an Serializable object in AIDL -

php - Improving script execution time -

How to provide Authorization & Authentication using Asp.net, C#? -