本文實例講述了C#華氏溫度和攝氏溫度相互轉換的方法。分享給大家供大家參考。具體如下:
public static double CelsiusToFahrenheit (string temperatureCelsius){ double celsius = System.Double.Parse (temperatureCelsius); return (celsius * 9 / 5) + 32; }public static double FahrenheitToCelsius (string temperatureFahrenheit){ double fahrenheit = System.Double.Parse (temperatureFahrenheit); return (fahrenheit - 32) * 5 / 9;}
希望本文所述對大家的C#程序設計有所幫助。
新聞熱點
疑難解答