Wednesday, August 11, 2010

How can we convert string into integer value in ASP.NET 3.5(visualstudio 2008)?

i use various ways as i see on net, but either they are not working or i was unable to implement themHow can we convert string into integer value in ASP.NET 3.5(visualstudio 2008)?
msgbox cstr(cint(';15';))How can we convert string into integer value in ASP.NET 3.5(visualstudio 2008)?
What is the error that you're receiving? What language are you using for the code behind? Post some code so that we can see where to help you.





I have chosen c# as an example of a couple of ways that you can go about converting a string to an int.





1:





// TryParse returns true if the conversion succeeded


// and stores the result in the specified variable.


int j;


bool result = Int32.TryParse(yourString, out j);


if (resul == ttrue)


Console.WriteLine(j);


else


Console.WriteLine(';String could not be parsed.';);





2:





Convert.ToInt32(yourString);





Hope that helps!

No comments:

Post a Comment