In a LINQ query:
from c in results
where c.ByteField == byteData
select c;
I'm getting no results from this even though the bytes are the same:
byte[5] = 49, 50, 51, 52, 53
How do I compare bytes properly in LINQ to Objects?
Thanks.
In LINQ to Objects (as your post suggests in the title), you can use IEnumerable.SequenceEqual()
:
from c in results
where c.ByteField.SequenceEqual(byteData)
select c;
Unfortunately, it looks like you're using LINQ to SQL (or Entity Framework) based on your use of context
. There's no SQL equivalent of SequenceEqual so this won't work in that case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With