Click here to Skip to main content
15,900,724 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
HI I have a payment form where I am catching one transaction id from gateway.
Its like 1234586475-58445-7445.I want to remove that hyphen in that string and then convert it into integer.Can anyone help me out.
Posted

C#
string str="1234586475-58445-7445";
int64 num=Convert.ToInt64(str.Replace("-","");
 
Share this answer
 
v2
The number you have chosen is too large. Perhaps a double would help you out.

C#
string s = "1234586475-58445-7445";
s = s.Replace("-","");
double d = Convert.ToDouble(s);
 
Share this answer
 
Comments
Radhika Vyas 23-Aug-12 6:33am    
It worked for me...Thank u.....
Matt T Heffron 23-Aug-12 14:50pm    
If he really needs the full value he could use System.Numerics.BigInteger (in .NET 4)
Try:
C#
string s = "1234586475-58445-7445";
s = s.Replace("-", "");
long l = long.Parse(s);

But you can't fit that number in an int - it's way too big! (maximum value in an int is 31 bits: 2147483647)
 
Share this answer
 
C#
string original=1234586475-58445-7445;
double value=Convert.ToDouble(original.Replace("-",""));
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900