C# 程式用於執行攝氏度到華氏度的轉換
首先,設定攝氏度 −
double celsius = 36; Console.WriteLine("Celsius: " + celsius);
現在轉換為華氏度
fahrenheit = (celsius * 9) / 5 + 32;
你可以嘗試執行以下程式碼將攝氏度轉換為華氏度。
例項
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Demo { class MyApplication { static void Main(string[] args) { double fahrenheit; double celsius = 36; Console.WriteLine("Celsius: " + celsius); fahrenheit = (celsius * 9) / 5 + 32; Console.WriteLine("Fahrenheit: " + fahrenheit); Console.ReadLine(); } } }
輸出
Celsius: 36 Fahrenheit: 96.8
廣告