For Programmers: Free Programming Magazines  


Home > Archive > C# > January 2005 > Convert String to int









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Convert String to int
jerry chapman

2005-01-26, 3:59 am

How can I convert a strint to an int?


cecil@ceciltech.com

2005-01-26, 3:59 am

Jerry
string s = "5000";
int i = string.Parse(s);
There is also an overload that lets you specify a number style to allow
for thousand separators, currency symbols etc...

Cecil Howell
MCT, MCSD, MCAD.Net
jerry chapman wrote:
> How can I convert a strint to an int?


Bruce Wood

2005-01-26, 3:58 pm

I think that you meant:

string s = "5000";
int i = Int32.Parse(s);

or you could use:

string s = "5000";
int i = Convert.ToInt32(s);

The String class doesn't have a Parse() method... it's the target
classes that have the Parse() methods.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com