J
Jim H
I will have many 3 byte Byte arrays. Is there a way to compare the values
without iterating through and comparing each element in the code?
Example:
byte[] lTest1 = new byte[3] {0x1, 0x2, 0x3};
byte[] lTest2 = new byte[3] {0x1, 0x2, 0x3};
byte[] lTest3 = new byte[3] {0x1, 0x5, 0x3};
if(Comparer.Equals(lTest1, lTest2))
System.Diagnostics.Trace.WriteLine("Test1 and Test2 are the same",
"Debug");
else
System.Diagnostics.Trace.WriteLine("Test1 and Test2 are the different",
"Debug");
if(lTest1 == lTest2)
System.Diagnostics.Trace.WriteLine("Test1 and Test2 are the same",
"Debug");
else
System.Diagnostics.Trace.WriteLine("Test1 and Test2 are the different",
"Debug");if(lTest1 == lTest3)
if(lTest1 == lTest3)
System.Diagnostics.Trace.WriteLine("Test1 and Test3 are the same",
"Debug");
else
System.Diagnostics.Trace.WriteLine("Test1 and Test3 are the different",
"Debug");
These all print out TestX and TestY are different. Are there any classes or
methods for comparing arrays by their value?
Thanks,
jim
without iterating through and comparing each element in the code?
Example:
byte[] lTest1 = new byte[3] {0x1, 0x2, 0x3};
byte[] lTest2 = new byte[3] {0x1, 0x2, 0x3};
byte[] lTest3 = new byte[3] {0x1, 0x5, 0x3};
if(Comparer.Equals(lTest1, lTest2))
System.Diagnostics.Trace.WriteLine("Test1 and Test2 are the same",
"Debug");
else
System.Diagnostics.Trace.WriteLine("Test1 and Test2 are the different",
"Debug");
if(lTest1 == lTest2)
System.Diagnostics.Trace.WriteLine("Test1 and Test2 are the same",
"Debug");
else
System.Diagnostics.Trace.WriteLine("Test1 and Test2 are the different",
"Debug");if(lTest1 == lTest3)
if(lTest1 == lTest3)
System.Diagnostics.Trace.WriteLine("Test1 and Test3 are the same",
"Debug");
else
System.Diagnostics.Trace.WriteLine("Test1 and Test3 are the different",
"Debug");
These all print out TestX and TestY are different. Are there any classes or
methods for comparing arrays by their value?
Thanks,
jim