I have some code that throws a null reference error:
72 if (query.allergy != null && query.allergy.Count > 0)
73 {
74 for (var i = 0; i < (query?.allergy?.Count ?? 0); i++) // <-- this line throws null reference exception
It seems I have null-checked everything here. How can it possibly throw a null reference error?
I don't have a chance to debug this remotely, so I don't know which part of the code is null.
Stack trace:
Object reference not set to an instance of an object. at XXXXXXXXX.Helpers.ProductHelper.processEntities(List`1 entities, String language) in C:\Users\XXXXXX\Dropbox\code\bots\XXXX\Helpers\ProductHelper.cs:line 74
I'm sure about the line number, I shifted the code by a few lines to make sure that this is this line, and the line number changed.