System.IndexOutOfRangeException: "The index was out of range of the array." c# ReadWriteMemory - C#