Convert Fahrenheit to Celsius with a function in CSharp

Description

The following code shows how to convert Fahrenheit to Celsius with a function.

Example


using System;//  w  ww .ja v  a  2s  .co m
using System.Data;
using System.Text.RegularExpressions;

class Class1{
        static void Main(string[] args){
            Console.WriteLine(FtoC(0));      
            Console.WriteLine(FtoC(40));      
            Console.WriteLine(FtoC(50));      
            Console.WriteLine(FtoC(-50));
        }
    public static double FtoC(double fahrenheit)
    {
      return ((0.5/0.9) * (fahrenheit - 32));
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Data Types »




C# Data Types
Bool
Byte
Char
Decimal
Double
Float
Integer
Long
Short
String
C# Array
Array Example
Byte Array
C# Standard Data Type Format
BigInteger
Complex
Currency
DateTime
DateTimeOffset
DateTime Format Parse Convert
TimeSpan
TimeZone
Enum
Null
tuple
var