I’d like to define a delegate that takes a couple of dates, an unknown number of other parameters (using the params keyword), and that returns a list of objects:
Func<DateTime, DateTime, params int[], List<object>>
Visual Studio doesn’t like the syntax which is making me think this isn’t allowed. Can anyone tell me why?
You can’t have custom attributes on a generic type argument (the CLI doesn’t permit it), and the C# compiler implements the
paramskeyword by emitting theSystem.ParamArrayAttributeon the relevant method parameter.This stops you from using it with the System.Func<…> generic delegates, but you can always create your own delegate type that does use
params.