86 {
88 int num = ((-1 == radix) ? 10 : radix);
89 if (num != 2 && num != 10 && num != 8 && num != 16)
90 {
92 }
95 {
96 throw new ArgumentOutOfRangeException(SR.ArgumentOutOfRange_Index);
97 }
98 if ((flags & 0x1000) == 0 && (flags & 0x2000) == 0)
99 {
102 {
103 throw new FormatException(SR.Format_EmptyInputString);
104 }
105 }
106 int num2 = 1;
108 {
109 if (num != 10)
110 {
112 }
113 if (((uint)flags & 0x200u) != 0)
114 {
115 throw new OverflowException(SR.Overflow_NegativeUnsigned);
116 }
117 num2 = -1;
119 }
120 else if (
s[i] ==
'+')
121 {
123 }
124 if ((radix == -1 || radix == 16) && i + 1 <
length &&
s[i] ==
'0' && (
s[i + 1] ==
'x' ||
s[i + 1] ==
'X'))
125 {
126 num = 16;
128 }
130 int num4 =
GrabInts(num,
s, ref i, (flags & 0x200) != 0);
131 if (i == num3)
132 {
133 throw new FormatException(SR.Format_NoParsibleDigits);
134 }
135 if (((uint)flags & 0x1000u) != 0 && i <
length)
136 {
137 throw new FormatException(SR.Format_ExtraJunkAtEnd);
138 }
140 if (((uint)flags & 0x400u) != 0)
141 {
142 if ((uint)num4 > 255u)
143 {
144 Number.ThrowOverflowException(TypeCode.SByte);
145 }
146 }
147 else if (((uint)flags & 0x800u) != 0)
148 {
149 if ((uint)num4 > 65535u)
150 {
151 Number.ThrowOverflowException(TypeCode.Int16);
152 }
153 }
154 else if (num4 == int.MinValue && num2 == 1 && num == 10 && (flags & 0x200) == 0)
155 {
156 Number.ThrowOverflowException(TypeCode.Int32);
157 }
158 if (num == 10)
159 {
160 num4 *= num2;
161 }
162 return num4;
163 }
static int GrabInts(int radix, ReadOnlySpan< char > s, ref int i, bool isUnsigned)
static void EatWhiteSpace(ReadOnlySpan< char > s, ref int i)