A friend was given an assignment at the interview, to explain why the code does not work, in general, he did not pass the interview, but we decided to sit on the test task together, didn’t come to any sensible result on our own, maybe you can tell what’s wrong here. The code is compiled, but is not executed.
class MiddleTask { delegate bool Comparer(int a, int b); delegate void Executer(string message); static int MaxValue(int a, int b, Comparer comp) { return comp(a, b) ? a : b; } static void TExecute(int cicle, Executer method) { var inc = 0; while (inc <--cicle) { method("Execute method-comparer"); } } static void Main(string[] args) { Trace.WriteLine("Entry point..."); TExecute(3, (dy) => { var targetRangeModel = new { range = 0, comparerPrefix = "Compare result:" }; var index = 0; var target = 20; while (index-- > targetRangeModel.range && target-- > index) { Trace.WriteLine(targetRangeModel.comparerPrefix + ">>>" + MaxValue(22, 15, (x, y) => { return (x > y) ? true : false; } ) ); } });