Function to convert a string to an integer
static int convert ( string s ) { int val = 0 ; char [ ] charArray = s . ToCharArray ( ) ; Array . Reverse ( charArray ) ; s = new string ( charArray ) ; int cur = 1 ; for ( int i = 0 ; i < s . Length ; i ++ ) { val += ( ( int ) s [ i ] - ( int ) '0' ) * cur ; cur *= 10 ; } return val ; }