How could i convert data from string to long in C#?
I have data
String strValue[i] =\"1100.25\";
now i want it in
long
You can also use long.TryParse
and long.Parse
.
long l1;
l1 = long.Parse("1100.25");
//or
long.TryParse("1100.25", out l1);
long is internally represented as System.Int64 which is a 64-bit signed integer. The value you have taken "1100.25" is actually decimal and not integer hence it can not be converted to long.
You can use:
String strValue = "1100.25";
decimal lValue = Convert.ToDecimal(strValue);
to convert it to decimal value
http://msdn.microsoft.com/en-us/library/system.convert.aspx
l1 = Convert.ToInt64(strValue)
Though the example you gave isn't an integer, so I'm not sure why you want it as a long.