This is a legacy code snippet that uses the magic goto, which I find it very difficult to understand and refactor.
doit:
foreach (var line in dict.Values)
{
var pts = new List<PointF>();
var rm = new Dictionary<string, LineData>();
doSomething(line, dict, pts, ref rm);
doSomethingWith(pts);
foreach (var item in rm.Values)
{
dict.Remove(item.ToString());
}
goto doit;
}
The goto doit jumps outside the loop. It isn't that bad because dict will eventually be cleared so that it does not cause endless loop.
How would you rewrite this? See answer here: https://helloacm.com/coding-review-how-would-you-convert-this-goto/