2

Could someone explain me how can this be possible:

foreach (var pair in Expected.Zip(
         Actual, (x, y) => new { Expected = x, Actual = y }))
{
    // No match for a 'null' series.
    if (pair.Actual == null) yield return 0;

    var actualPaths = pair.Actual.Images.Select(x => x.Path).ToList();
}

This code (in Microsoft Visual Studio 2008) stops on line var actualPaths = ... and says that pair.Actual equals null, therefore raising a NullReferenceException.

How is this even possible? Am I missing something?

1
  • How does it say that pair.Actual is null? Commented Mar 31, 2011 at 1:59

1 Answer 1

8

After your if, the rest of the code keeps running.

You need to add continue;, or put the rest of the code in an else block.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.