首页 > 编程 > C# > 正文

C#华氏温度和摄氏温度相互转换的方法

2019-10-29 21:40:12
字体:
来源:转载
供稿:网友

这篇文章主要介绍了C#华氏温度和摄氏温度相互转换的方法,涉及C#数学运算的相关技巧,非常简单实用,需要的朋友可以参考下

本文实例讲述了C#华氏温度和摄氏温度相互转换的方法。分享给大家供大家参考。具体如下:

 

 
  1. public static double CelsiusToFahrenheit (string temperatureCelsius) 
  2. double celsius = System.Double.Parse (temperatureCelsius); 
  3. return (celsius * 9 / 5) + 32;  
  4. public static double FahrenheitToCelsius (string temperatureFahrenheit) 
  5. double fahrenheit = System.Double.Parse (temperatureFahrenheit); 
  6. return (fahrenheit - 32) * 5 / 9; 

希望本文所述对大家的C#程序设计有所帮助。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表