In addition, other characters in the string may also mess up the parsing.
For instance, suppose that you have y=" 4 ". Although that does look like
the number four, it has spaces around it which might cause parse problems.
If the user is entering this information in a textbox, then you might assume
the data is bad since the user could enter anything and you might have to
clean it up before parsing it.
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:u3*************@TK2MSFTNGP15.phx.gbl...
y can't be = 4 because it's a string....
if y = "4"; then Int.Parse(y) should work...so it's probably something
other than "4"
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"sara" <sa**@discussions.microsoft.com> wrote in message
news:92**********************************@microsof t.com... Thanks Hans
let say y=4;
"Hans Kesting" wrote:
sara wrote:
> Hi to all
> i have
> string y;
> int x=int.parse(y);
> when i run the application this exeption is trewn
> ///////////////////////////////////////
> Description: An unhandled exception occurred during the execution of the > current web request. Please review the stack trace for more information about > the error and where it originated in the code.
>
> Exception Details: System.FormatException: Input string was not in a correct > format.
>
> Source Error:
>
> Line 106: string Bind=txtBimsID.Text.ToString();
> Line 107: //////////////////////////////////
> Line 108: int Ax=int.Parse(y);
>
> Plz any help
> Thanks
>
>
>
What is the value of string "y"? The error says that it
doesn't look like a correct number.
Just a sidenote: The "Text" property of (I'm guessing) a TextBox
already gives a string value. No need to use ToString() there.
--
Hans Kesting