Posted
Filed under C#

[refference]http://stackoverflow.com/questions/3395381/c-sharp-converting-a-string-containing-a-floating-point-to-an-integer

var
a =(int)Convert.ToDouble("1.2");

Note if you're using comma as a number separator in your operating system, you have to use IFormatProvider:

var a =(int)Convert.ToDouble("1.2",CultureInfo.InvariantCulture.NumberFormat);

Another way to accomplish this task:

var a =int.Parse("1.2".Split('.')[0]);

2016/02/12 18:38 2016/02/12 18:38