|
-
May 23rd, 2002, 06:49 AM
#1
String to integer
Hi every body!
Could someone help me in converting a string to integer in C#?
Thanks.
-
May 23rd, 2002, 07:11 AM
#2
You can use the System.Convert class.
Like this:
int iNumber = System.Convert.ToInt32(myString);
-
May 23rd, 2002, 01:36 PM
#3
Easy way of converting a string to an interger
int i = Int32.Parse(String);
Similarly converting a string to a long is done as
long d = Int64.Parse(String);
-
May 24th, 2002, 01:29 AM
#4
Also works..
Similar to what armtusk replied, the following also works (just a matter of taste, I think using the same datatypes adds to more consistant code):
int i = int.Parse(String);
or
long d = long.Parse(String);
Of course, it also works with doubles and floats .
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|