private void ConvertButton_Click(object sender, EventArgs e) { if (!double.TryParse(inputTemperature.Text, out double inputValue)) { MessageBox.Show("Введите число!"); return; } try { outputTemperature.Text = $"{_converter.Convert(inputValue, fromScale.SelectedItem.ToString(), toScale.SelectedItem.ToString()):f1}"; } catch (Exception error) { MessageBox.Show(error.Message); } }
static void Main(string[] args) { var converter = new TemperatureConverter(); Console.WriteLine(converter.Convert(0, "Kelvin", "Celsius")); }