Convert Celsius to Fahrenheit with a function in CSharp
Description
The following code shows how to convert Celsius to Fahrenheit with a function.
Example
using System;//ww w.ja va 2 s. c o m
using System.Data;
class Class1{
static void Main(string[] args){
Console.WriteLine(CtoF(0));
Console.WriteLine(CtoF(40));
Console.WriteLine(CtoF(50));
Console.WriteLine(CtoF(-50));
}
public static double CtoF(double celsius)
{
return (((0.9/0.5) * celsius) + 32);
}
}
The code above generates the following result.