There's something else wrong with your approach.
Are the two arguments supposed to be always SessionStateService.Var1
and SessionStateService.Var2
? Or will those be the delegate's arguments?
If you want them to be the delegate's parameters:
Func<string, string, IEnumerable<MyPOCO>> del =
WCFServiceInstance.GetLabs;
del(SessionStateService.Var1, SessionStateService.Var2);
If you want the method be invoked with those specific values, use a closure instead:
Func<IEnumerable<MyPOCO>> del =
() => WCFServiceInstance.GetLabs(SessionStateService.Var1, SessionStateService.Var2);
del();
Bear in mind that if you use a closure, SessionStateService.Var1
and SessionStateService.Var2
will be evaluated when the delegate is called (line 2), not when it is declared (line 1). So, if you pass this second delegate around and call it later, the values of the arguments might have changed.
If you want to prevent that, you can use eager evaluation, as exemplified by @knittl in the comments:
string var1 = SessionStateService.Var1,
var2 = SessionStateService.Var2;
Func<IEnumerable<MyPOCO>> del = () => WCFServiceInstance.GetLabs(var1, var2);