@@ -108,8 +108,8 @@ public static IPAddress Parse(string ipString)
108108 else
109109 {
110110 i = i == length - 1 ? ++ i : i ;
111- octet = ( ulong ) ( ConvertStringToInt32 ( ipString . Substring ( lastIndex , i - lastIndex ) ) & 0x00000000000000FF ) ;
112- ipAddress = ipAddress + ( ulong ) ( ( octet << shiftIndex ) & mask ) ;
111+ octet = ulong . Parse ( ipString . Substring ( lastIndex , i - lastIndex ) ) & 0x00000000000000FF ;
112+ ipAddress = ipAddress + ( ( octet << shiftIndex ) & mask ) ;
113113 lastIndex = i + 1 ;
114114 shiftIndex = shiftIndex + 8 ;
115115 mask = ( mask << 8 ) ;
@@ -140,57 +140,6 @@ public override string ToString()
140140 ( ( byte ) ( m_Address >> 24 ) ) . ToString ( ) ;
141141 }
142142
143- //--//
144- ////////////////////////////////////////////////////////////////////////////////////////
145- // this method ToInt32 is part of teh Convert class which we will bring over later
146- // at that time we will get rid of this code
147- //
148-
149- /// <summary>
150- /// Converts the specified System.String representation of a number to an equivalent
151- /// 32-bit signed integer.
152- /// </summary>
153- /// <param name="value">A System.String containing a number to convert.</param>
154- /// <returns>
155- /// A 32-bit signed integer equivalent to the value of value.-or- Zero if value
156- /// is null.
157- /// </returns>
158- private static int ConvertStringToInt32 ( string value )
159- {
160- char [ ] num = value . ToCharArray ( ) ;
161- int result = 0 ;
162-
163- bool isNegative = false ;
164- int signIndex = 0 ;
165-
166- if ( num [ 0 ] == '-' )
167- {
168- isNegative = true ;
169- signIndex = 1 ;
170- }
171- else if ( num [ 0 ] == '+' )
172- {
173- signIndex = 1 ;
174- }
175-
176- int exp = 1 ;
177- for ( int i = num . Length - 1 ; i >= signIndex ; i -- )
178- {
179- if ( num [ i ] < '0' || num [ i ] > '9' )
180- {
181- throw new ArgumentException ( ) ;
182- }
183-
184- result += ( ( num [ i ] - '0' ) * exp ) ;
185- exp *= 10 ;
186- }
187-
188- return ( isNegative ) ? ( - 1 * result ) : result ;
189- }
190-
191- // this method ToInt32 is part of teh Convert class which we will bring over later
192- ////////////////////////////////////////////////////////////////////////////////////////
193-
194143 /// <summary>
195144 /// Retrieves an IP address that is the local default address.
196145 /// </summary>
0 commit comments