I am getting an unusual "NullReferenceException was unhandled by user code" error in this LINQ query:
List<UDIDInfo> d2Android = d2.Where(x.DeviceOS == (byte)DeviceOS.Android).ToList();
I went ahead and added a null check and am still getting the error
List<UDIDInfo> d2Android = d2.Where(x => x.DeviceOS != null && x.DeviceOS == (byte)DeviceOS.Android).ToList();
Note that (byte)DeviceOS.Android
and d2
are both not null
Edit (Solution):
List<UDIDInfo> d2Android = d2.Where(x => x != null && x.DeviceOS != null && x.DeviceOS == (byte)DeviceOS.Android).ToList();