Hello! Recently I began to study delegates and decided to try them in practice. I wrote a method for calculating the average execution time of a method:
public delegate void FunctionDelegate(); static public long SpeedTest(FunctionDelegate del, int numberIterations) { var stopWatch = new Stopwatch(); var listValue = new List<long>(); for (var index = 0; index < numberIterations; index++) { stopWatch.Restart(); del(); stopWatch.Stop(); listValue.Add(stopWatch.ElapsedMilliseconds); } return listValue.Sum() / listValue.Count; } And the question arose, is it possible to make such a delegate so that any method can be shoved into it, and then even any parameters passed?
Something like that:
public delegate Object FunctionDelegate(params object[] args);