字节数组比较大小
1 /// <summary>
2 /// 字節數組比較
3 /// </summary>
4 /// <param name="bytearray1">字節數組 1</param>
5 /// <param name="bytearray2">字節數組 2</param>
6 /// <returns>如果兩個數組相同,返回0;如果數組1大于數組2,返回負值;反之,則返回值大于0。</returns>
7 public int MemoryCompareByteArray(byte[] bytearray1, byte[] bytearray2)
8 {
9 int result = 0;
10 if (bytearray1.Length != bytearray2.Length)
11 {
12 result = bytearray1.Length - bytearray2.Length;
13 }
14 else
15 {
16 for (int i = 0; i < bytearray1.Length; i++)
17 {
18 if (bytearray1[i] != bytearray2[i])
19 {
20 result = (int)(bytearray1[i] - bytearray2[i]);
21 break;
22 }
23 }
24 }
25 return result;
26 }
?
轉載于:https://www.cnblogs.com/craigtao/p/3610817.html
總結
- 上一篇: cgi硬盘安装器_系统镜像安装CGI备份
- 下一篇: ubuntu 16.04 源码安装sam