public static char[] AllocateCharArray(int size)
 {
     char[] chArray;
     try
     {
         chArray = new char[size];
     }
     catch (OutOfMemoryException exception)
     {
         throw Exception.AsError(new InsufficientMemoryException(SRCore.BufferAllocationFailed(size * 2), exception));
     }
     return(chArray);
 }
 public static byte[] AllocateByteArray(int size)
 {
     byte[] buffer;
     try
     {
         buffer = new byte[size];
     }
     catch (OutOfMemoryException exception)
     {
         throw Exception.AsError(new InsufficientMemoryException(SRCore.BufferAllocationFailed(size), exception));
     }
     return(buffer);
 }