private int GetDecimalCharEntity(int offset, int length)
{
byte[] buffer = _buffer;
DiagnosticUtility.DebugAssert(buffer[offset + 0] == '&', "");
DiagnosticUtility.DebugAssert(buffer[offset + 1] == '#', "");
DiagnosticUtility.DebugAssert(buffer[offset + length - 1] == ';', "");
int value = 0;
for (int i = 2; i < length - 1; i++)
{
byte ch = buffer[offset + i];
if (ch < (byte)'0' || ch > (byte)'9')
XmlExceptionHelper.ThrowInvalidCharRef(_reader);
value = value * 10 + (ch - '0');
if (value > SurrogateChar.MaxValue)
XmlExceptionHelper.ThrowInvalidCharRef(_reader);
}
return value;
}