Reputation: 561
I have a byte array and a byte list, they both contains same numbers. how should I compare them.
code i am using, but not working:
if (portBuffer.Equals(ret_bytes))
status = 0;
The following image is captured when i was debugging. they basicly contains same bytes. I know they are belonging to different object, but how to cast them? thanks
a busy cat http://img29.imageshack.us/img29/5769/33818425.jpg !
Upvotes: 0
Views: 984
Reputation: 4028
use the extension method SequenceEqual.
using System.Linq;
//...
if (portBuffer.SequenceEqual(ret_bytes))
status = 0;
Upvotes: 3
Reputation: 1638
If you want to use linq, try:
var arraysAreEqual = Enumerable.SequenceEqual(portBuffer, ret_bytes);
I am not at my pc so I cannot tell you if any casting is needed.
Upvotes: 2