8

I have a method signature

bool TryGetItem(string itemKey,out Item item)

How can i encapsulate this signature in

delegate V Func<T,U,V>(T input, out U output)

as in the post: Func<T> with out parameter ?

Community
  • 1
  • 1
Muddassir
  • 83
  • 1
  • 5

1 Answers1

8

You are just written answer.

If you in .net 4.0 or above you can specify variance for parameters.

public delegate TV MyFunc<in T, TU, out TV>(T input, out TU output);

Then use:

bool TryGetItem(string itemKey,out Item item);

MyFunc<string, Item, bool> func = TryGetItem;
Hamlet Hakobyan
  • 32,965
  • 6
  • 52
  • 68