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

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

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -