1.11. Converting Celsius to Fahrenheit

Problem

You have a temperature reading measured in Celsius and need to convert it to Fahrenheit.

Solution

public static double CtoF(double celsius)
{
    return (((0.9/0.5) * celsius) + 32);
}

Discussion

This recipe makes use of the following Celsius-to-Fahrenheit temperature conversion equation:

TempFahrenheit = ((9 / 5) * TempCelsius) + 32

The Fahrenheit temperature scale is widely used in the United States. However, much of the rest of the world uses the Celsius temperature scale.

Get C# Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.