How I can get number from following string:
###E[shouldbesomenumber][space or endofline]
[] here only for Illustration not present in the real string.
I am in .net 2.0.
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I would suggest that you use regular expressions or string operations to isolate just the numeric part, and then call
int.Parse,int.TryParse,decimal.Parse,decimal.TryParseetc depending on the type of number you need to parse.The regular expression might look something like:
You’ll need to change it for non-integers, of course. Sample code:
Note that this could still fail with a number which exceeds the range of
int. (Another reason to useint.TryParse…)