這篇文章主要介紹了C#華氏溫度和攝氏溫度相互轉換的方法,涉及C#數學運算的相關技巧,非常簡單實用,需要的朋友可以參考下
本文實例講述了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#程序設計有所幫助。
新聞熱點
疑難解答