The C# team posts answers to common questions and describes new language features
You can use the Convert class or the Parse method of the built-in type you are casting to. i.e.
This example uses the int type, but you can also use the same techniques for any of the other integral or floating point types.
[Author: Joe Mayo]
PingBack from http://www.moveandlive.net/blog/?p=6
PingBack from http://www.moveandlive.net/blog/?p=19
MSDN article: "How to: Determine Whether a String Represents a Numeric Value (C# Programming Guide)".
msdn.microsoft.com/.../bb384043(v=VS.90).aspx
In short, this is what Microsoft suggests:
int i = 0;
string s = "108";
bool result = int.TryParse(s, out i); //i now = 108
After the above code executes,:
If the string can be successfully converted, the variable "i" will contain it value and the variable "result" will equal true. The above article has more examples.
Thank u Mr.Dave Moss, I got the Result
Here is a post on this
dotnetrobert.com
Obrigado por contribuir para a comunidade de desenvolvedores.
Eu compartilho informações parecidas por meio do artigo entitulado
[Como Tratar Exceção ao Converter String para Número Inteiro (Int32) com C#], disponível em cavas.com.br/.../como-tratar-excecao-ao-converter-string-para-numero-inteiro-int32-com-c
Thanks for contributing to the developer community. I share similar information through the article titled [How to Handle Exception to Convert String to Integer (Int32) with C #], or in portuguese, [Como Tratar Exceção ao Converter String para Número Inteiro (Int32) com C#] available at cavas.com.br/.../como-tratar-excecao-ao-converter-string-para-numero-inteiro-int32-com-c