What is the fastest way to compare two byte arrays?

后端 未结 6 1505
你的背包
你的背包 2021-01-18 07:59

I am trying to compare two long bytearrays in VB.NET and have run into a snag. Comparing two 50 megabyte files takes almost two minutes, so I\'m clearly doing something wron

6条回答
  •  余生分开走
    2021-01-18 08:20

    If you don't need to know the byte, use 64-bit ints that gives you 8 at once. Actually, you can figure out the wrong byte, once you've isolated it to a set of 8.

    Use BinaryReader:

    saveTime  = binReader.ReadInt32()
    

    Or for arrays of ints:

    Dim count As Integer = binReader.Read(testArray, 0, 3)
    

提交回复
热议问题