private void TempUnitComboBoxSelectedIndexChanged(object sender, EventArgs e) { if (double.TryParse(oatTxtBox.Text, out var temp)) { if (tempUnitComboBox.SelectedIndex == 0) { // deg F -> deg C temp = ConversionTools.ToCelsius(temp); } else { // deg C -> deg F temp = ConversionTools.ToFahrenheit(temp); } oatTxtBox.Text = Numbers.RoundToInt(temp).ToString(); } }
private int TempConvertUnit(double tempCelsuis, TemperatureUnit tempUnit) { return(Numbers.RoundToInt(tempUnit == TemperatureUnit.Fahrenheit ? ConversionTools.ToFahrenheit(tempCelsuis) : tempCelsuis)); }