比方說,我有兩個字節數組,每個包含像一系列的值:字節數組模式匹配
byte[] b = {50,60,70,80,90,10,20,1,2,3,4,5,50,2,3,1,2,3,4,5};
byte[] b2 = {1,2,3,4,5}
我可以比較這兩個數組,並查找使用LINQ方法相同的值。這樣,如果我在這兩個數組之間進行比較,結果將是b數組的索引,其中b2數組的索引中的值是匹配的。
我一直在試圖精確地找到b數組在b數組中循環的範圍。我的意思是
if (TheLenghtOfSearch==5) {Now the indexes of two regions must be return }
Result ->(7, 11), (15, 19)
if (TheLenghtOfSearch==2) {Now the indexes of around 9 regions where the two consecutive values in b2 recurred in b must be returned}
Result ->(7, 8), (15, 16), (8, 9), (13, 14), (16, 17), (9, 10), (17, 18), (10, 11), (18, 19)
我想解決方案更數學。
你試圖在你的例子中得到什麼樣的結果? – Maris
b數組中的索引 – Transcendent
您可以將字節數組轉換爲字符串並執行字符串搜索 –