double fahrenheit = 97;console.writeline("fahrenheit: " + fahrenheit);
现在将其转换为摄氏度 -
celsius = (fahrenheit - 32) * 5 / 9;
示例您可以尝试运行以下代码将华氏温度转换为摄氏度。
现场演示
using system;using system.collections.generic;using system.linq;using system.text;namespace demo { class myapplication { static void main(string[] args) { double celsius; double fahrenheit = 97; console.writeline("fahrenheit: " + fahrenheit); celsius = (fahrenheit - 32) * 5 / 9; console.writeline("celsius: " + celsius); console.readline(); } }}
输出fahrenheit: 97celsius: 36.1111111111111
以上就是将华氏温度转换为摄氏度的 c# 程序的详细内容。