BEncodeLib.TorrentBDecoder.DecodeLong C# (CSharp) Метод

DecodeLong() приватный Метод

private DecodeLong ( ) : long
Результат long
        private long DecodeLong()
        {
            int c = GetNextIndicator();

            if (c != 'i')
                throw new FormatException("Expected 'i', not '" + (char) c + "'");

            _indicator = 0;

            c = Read();
            if (c == '0')
            {
                c = Read();
                if (c == 'e')
                    return 0;
                else
                    throw new FormatException("'e' expected after zero," + " not '" + (char) c + "'");
            }

            var chars = new char[256];
            int off = 0;

            if (c == '-')
            {
                c = Read();
                if (c == '0')
                    throw new FormatException("Negative zero not allowed");
                chars[off] = (char) c;
                off++;
            }

            if (c < '1' || c > '9')
                throw new FormatException("Invalid Integer start '" + (char) c + "'");

            chars[off] = (char) c;
            off++;

            c = Read();
            int i = c - '0';
            while (i >= 0 && i <= 9)
            {
                chars[off] = (char) c;
                off++;
                c = Read();
                i = c - '0';
            }

            if (c != 'e')
                throw new FormatException("Integer should end with 'e'");

            var s = new String(chars, 0, off);

            return long.Parse(s);
        }