Đầu tiên, đặt nhiệt độ C -
double celsius = 36;
Console.WriteLine("Celsius: " + celsius); Bây giờ chuyển nó thành Fahrenheit:
fahrenheit = (celsius * 9) / 5 + 32;
Bạn có thể thử chạy đoạn mã sau để chuyển độ C sang độ F.
Ví dụ
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();
}
}
} Đầu ra
Celsius: 36 Fahrenheit: 96.8