111,093
社区成员




public int GetIndexOf(byte[] b, byte[] bb)
{
if (b == null || bb == null || b.Length == 0 || bb.Length == 0 || b.Length<bb.Length)
return -1;
int i, j;
for (i = 0; i < b.Length - bb.Length + 1; i++)
{
if (b[i] == bb[0])
{
for (j = 1; j < bb.Length; j++)
{
if (b[i + j] != bb[j])
break;
}
if (j == bb.Length)
return i;
}
}
return -1;
}
public int GetIndexOf(byte[] b, byte[] bb)
{
if (b == null || bb == null || b.Length == 0 || bb.Length == 0)
return -1;
int i, j;
for (i = 0; i < b.Length; i++)
{
if (b[i] == bb[0])
{
for (j = 1; j < bb.Length; j++)
{
if (b[i + j] != bb[j])
break;
}
if (j == bb.Length)
return i;
}
}
return -1;
}
//调用代码
byte[] b = { 1, 2, 3, 4, 6, 0, 4, 6 };
byte[] bb = { 4, 6 };
int i = GetIndexOf(b, bb);