unkwntech

SubArray

Oct 5th, 2012
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.31 KB | None | 0 0
  1. private static byte[] SubArray(byte[] arr, int start, int count = 0, bool maintainKeys = false)
  2. {
  3.     if (count == 0)
  4.     {
  5.         count = arr.Length - start;
  6.     }
  7.  
  8.     byte[] result = new byte[count];
  9.  
  10.     for (int i = start, j = 0; j < count; i++, j++)
  11.     {
  12.         result[maintainKeys ? i : j] = arr[i];
  13.     }
  14.     return result;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment