Reputation: 101
I'm getting an error off of the following code asking if I want to invoke this method:
protected void CheckForLocalPickPlace(JobList jobs)
{
if (CachedAnonymousMethodDelegate1 == null)
{
CachedAnonymousMethodDelegate1 = new Predicate<JobClass>(null, (IntPtr) CheckForLocalPickPlace);
}
this.localPickPlace = jobs.TrueForAll(CachedAnonymousMethodDelegate1);
}
Upvotes: 0
Views: 7677
Reputation: 66573
This expression is invalid:
new Predicate<JobClass>(null, (IntPtr) CheckForLocalPickPlace)
If CheckForLocalPickPlace
is a method, then you probably meant to put this:
new Predicate<JobClass>(CheckForLocalPickPlace)
If it is not a method, please describe in more detail what you are trying to do.
Upvotes: 0
Reputation: 1500893
I believe the problem is the way you're trying to construct the delegate, although you haven't specified much in the way of types.
You can't build a Predicate<JobClass>
from CheckForLocalPickPlace
because the signature is wrong, but if you could you could just do:
CachedAnonymousMethodDelegate1 = CheckForLocalPickPlace;
or
CachedAnonymousMethodDelegate1 = new Predicate<JobClass>(CheckForLocalPickPlace);
If you could give us a lot more context, we can try to help you more.
Upvotes: 3
Reputation: 44307
Unlike some languages (e.g. Delphi), C# requires that you put the brackets after a method to call it.
IIRC, this comes from the definition of the C language where ()
is the operator to call a function.
Upvotes: 1
Reputation: 2595
this.ClearJobs Is that a function? If it is, it should be this.ClearJobs()
Upvotes: 2