Is it possible to rewrite the following code in a single statement?
foreach(var myVar in varEnumerable)
{
MyMethod(myVar);
Thread.Sleep(2000);
}
Without the Thread.Sleep()
, I would've written it as:
varEnumerable.ToList().ForEach(x => MyMethod(x));