Is there a nicer way of doing the following:
I need a check for null to happen on file.Headers before proceeding with the loop
if (file.Headers != null)
{
foreach (var h in file.Headers)
{
//set lots of properties & some other stuff
}
}
In short it looks a bit ugly to write the foreach inside the if due to the level of indentation happening in my code.
Is something that would evaluate to
foreach(var h in (file.Headers != null))
{
//do stuff
}
possible?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…