443,889 Members | 1,358 Online
Need help? Post your question and get tips & solutions from a community of 443,889 IT Pros & Developers. It's quick & easy.

# Convert srting "(192)"

 P: n/a HI all, I have imported string data that contains numerical values. The negatives are reporesented in round braces () as in (192) representing -192. How can I convert thin string into a negative number while converting other numbers as positive numerical data Thanks Robert Jul 22 '06 #1
4 Replies

 P: n/a using System.Globalization; string num = "(192)"; int foo = int.Parse(num, NumberStyles.AllowParentheses); Console.WriteLine(foo); Cheers, Greg Young MVP - C# http://codebetter.com/blogs/gregyoung "Robert Bravery"

 P: n/a Hello Robert, There are a lot of variations - regexp, checking "(" existence and etc Smth like using String.Replace to replace the "(" on "-", remove "-" and Convert.ToInt32(<your_string>) RBHI all, RB> RBI have imported string data that contains numerical values. The RBnegatives are reporesented in round braces () as in (192) RBrepresenting -192. How can I convert thin string into a negative RBnumber while converting other numbers as positive numerical data RB> RBThanks RBRobert --- WBR, Michael Nemtsev :: blog: http://spaces.msn.com/laflour "At times one remains faithful to a cause only because its opponents do not cease to be insipid." (c) Friedrich Nietzsche Jul 22 '06 #3

 P: n/a Thanks All Robert "Robert Bravery"

 P: n/a Hello Greg, Gotcha! it catched from my mind GYusing System.Globalization; GY> GYstring num = "(192)"; GYint foo = int.Parse(num, NumberStyles.AllowParentheses); GYConsole.WriteLine(foo); GYCheers, GY> GYGreg Young GYMVP - C# GYhttp://codebetter.com/blogs/gregyoung GY"Robert Bravery" >HI all,I have imported string data that contains numerical values. Thenegativesare reporesented in round braces () as in (192) representing -192.How canIconvert thin string into a negative number while converting othernumbersaspositive numerical dataThanksRobert --- WBR, Michael Nemtsev :: blog: http://spaces.msn.com/laflour "At times one remains faithful to a cause only because its opponents do not cease to be insipid." (c) Friedrich Nietzsche Jul 22 '06 #5

### This discussion thread is closed

Replies have been disabled for this discussion.