C
C#3y ago
Connor

❔ Enumerable.Current is not null in debug mode but assigns null to variable

I know I'm not exactly following the best practices with the reader but this code should work none the less. The debuging shows that the Current property is populated but for some reason still assigns null to _currentModel;
5 Replies
Connor
ConnorOP3y ago
private IEnumerable<CommentModel> _commentsEnumerable;
private CommentModel _currentModel;
private IEnumerable<CommentModel> _commentsEnumerable;
private CommentModel _currentModel;
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
canton7
canton73y ago
You: 1. Created an enumerable, stored it in _commentEnumerable 2. Created a new enumerator from _commentsEnumerable, called MoveNext() on it, and then threw it away 3. Created another new enumerator from _commentsEnumerable, didn't call MoveNext() on it (so it's still in it's "still at the start" state and Current is null 4. Are wondering whe the Current of that second enumerator is null? I'm not clear on what object you're inspecting there, but surely the issue is that you're creating an enumerator, calling MoveNext, and then throwing it away?
ero
ero3y ago
Who needs to dispose enumerators right
Accord
Accord3y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server