The C# compiler is not as smart as you are. Even though you know that there will always be something to loop through, the compiler does not.
Because of this, the compiler thinks there is a chance that intf
is empty in which case Interfaces
will never be assigned. Since you are trying to call Save(..);
on Interfaces
after the loop, the compiler complains.
That being said, it seems like you are reassigning Interfaces
in every loop, without using the result from the previous iterations(thereby throwing away the previous iterations XDocuments
). Is this intentional?