ReSharper notifies me of the possible System.NullReferenceExceptionfor the following code:
System.NullReferenceException
IEnumerator<IEdgeData> edgeEnumerator = edgeData.GetEnumerator(); while (edgeEnumerator.MoveNext()) { ConvId fromConvId = edgeEnumerator.Current.From; ... }
In particular, this emphasizes:
edgeEnumerator.Current
I cannot understand under what circumstances an exception can occur. I understand that the internal while-loops statements will only be executed if they MoveNext()can set an enumerator for the next element.
while
MoveNext()
The next element may be null. For example, the following code:
new List<SampleClass> { null, null, null }
still give you an enumeration for each element, but the element itself is null.