class Example
{
public static void Main()
{
double x, y;
int i;
x = 10.0;
y = 3.0;
// cast double to int, fractional component lost (Line to be replaced)
i = (int) (x / y);
Console.WriteLine("Integer outcome of x / y: " + i);
}
}
double testeDouble_min = 12.3456;
double testeDouble_max = 12.8456;
double emptyDouble;
int i01_min = Convert.ToInt32(testeDouble_min); //12
int i01_max = Convert.ToInt32(testeDouble_max); //13
//var erro = Convert.ToInt32(emptyDouble); //error
int i02_min = (int)testeDouble_min; //12
int i02_max = (int)testeDouble_max; //12
//var erro = (int)emptyDouble; //error
var styles = System.Globalization.NumberStyles.Integer | System.Globalization.NumberStyles.AllowDecimalPoint;
var provider = new System.Globalization.CultureInfo("en-US");
bool success = int.TryParse(testeDouble_min.ToString(), styles, provider, out int i03_min); //0
_ = int.TryParse(testeDouble_max.ToString(), out int i03_max); //0 because it has decimal place, if it didn't have ok
int i04_min = (int)Math.Round(testeDouble_min, MidpointRounding.AwayFromZero); //12
int i04_max = (int)Math.Round(testeDouble_max, MidpointRounding.AwayFromZero); //13