Byte array Index Of

image_pdfimage_print

//GNU General Public License version 2 (GPLv2)
//http://walkmen.codeplex.com/license

using System;
using System.Collections.Generic;
using System.Text;

namespace Walkmen.Util
{
public sealed class ByteUtils
{
private ByteUtils()
{
}

public static int IndexOf(byte[] array, byte[] pattern, int offset)
{
int success = 0;
for (int i = offset; i < array.Length; i++) { if (array[i] == pattern[success]) { success++; } else { success = 0; } if (pattern.Length == success) { return i - pattern.Length + 1; } } return -1; } } } [/csharp]

This entry was posted in Data Types. Bookmark the permalink.