public string convertTemperature(string Celsius, string Fahrenheit, string convert) { try { decimal num = 0; decimal res = 0; _convert.Fahrenheit = 0; _convert.Celsius = 0; if (decimal.TryParse(Celsius, out num)) { _convert.Celsius = decimal.Parse(Celsius); } if (decimal.TryParse(Fahrenheit, out num)) { _convert.Fahrenheit = num; } if (convert == "ctof") { res = _convert.CelsiusToFahrenheit(); } else { res = _convert.FahrenheitToCelsius(); } return(res.ToString()); } catch (Exception ex) { return("Problem in conversion..."); } }