CSharp examples for System:Byte Array
Copy Subset from byte array
public class Main{ public static byte[] CopySubset(this byte[] source, int sourceStartIndex) {/*from w ww . j av a 2 s . com*/ byte[] destination = new byte[source.Length - sourceStartIndex]; destination.CopyFrom(source, sourceStartIndex); return destination; } // requires destination to be pre-sized public static int CopyFrom(this sbyte[] destination, byte[] source, int sourceStartIndex) { for (int i = 0; i < destination.Length; i++) { destination[i] = (sbyte)source[sourceStartIndex++]; } return sourceStartIndex; } // requires destination to be pre-sized public static int CopyFrom<T>(this T[] destination, T[] source, int sourceStartIndex) { for (int i = 0; i < destination.Length; i++) { destination[i] = source[sourceStartIndex++]; } return sourceStartIndex; } }