tags:

views:

51

answers:

2

I have a delegate:

    delegate ResultType Caller<ResultType>(IPtxLogic logic);

Here is a function:

private ResultType ExecuteLogicMethod2<ResultType>(string sessionId,
    Caller<ResultType> action) 
    where ResultType : IResult, new()
    {...}

I want to replace the function signature with something like this:

private ResultType ExecuteLogicMethod2<ResultType>(string sessionId,
    Action<IPtxLogic, ResultType> action)
    where ResultType : IResult, new()
    {...}

Compiler tells me:

Using the generic type 'System.Action' requires '1' type arguments

Why? How can I get access to 'standard' .NET class?

Thank you. Any thought are welcome.

P.S. I've created my custom delegate to resolve issue, but ... I don't want to create custom delegate for each of my 'custom action'...

delegate ResultType Action<ParameterType, ResultType>(ParameterType param);

P.P.S. I am using .NET 3.5

+4  A: 

Make sure you reference System.Core.dll and using System.Linq;

On second thought. You are using Action in place of Func.

You need Func<IPtxLogic, ResultType>.

leppie
`Action` and `Func` are in the `System` namespace. However the OP's error message suggests they've got `using System;` but are missing a reference to _System.Core.dll_.
Tim Robinson
@Tim Robinson: Nope, it was not THAT :)
leppie
A: 

leppie, your original thought was right:

  1. I need to add 'System.Core' assembly into project!
  2. I need to use Func<> // but this is not a core of the problem

Thanks.

These types are included into 3.5 out-of-the-box: http://msdn.microsoft.com/en-us/library/bb534960.aspx

Version Information .NET Framework Supported in: 4, 3.5

Budda