static private ValidateWriteParameters ( char buffer, int offset, int count ) : void | ||
buffer | char | |
offset | int | |
count | int | |
return | void |
internal static void ValidateWriteParameters(char[] buffer, int offset, int count)
{
if (buffer == null)
{
throw ADP.ArgumentNull(nameof(buffer));
}
if (offset < 0)
{
throw ADP.ArgumentOutOfRange(nameof(offset));
}
if (count < 0)
{
throw ADP.ArgumentOutOfRange(nameof(count));
}
try
{
if (checked(offset + count) > buffer.Length)
{
throw ExceptionBuilder.InvalidOffsetLength();
}
}
catch (OverflowException)
{
// If we've overflowed when adding offset and count, then they never would have fit into buffer anyway
throw ExceptionBuilder.InvalidOffsetLength();
}
}
}