ขั้นแรก ตั้งอุณหภูมิเซลเซียส −
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