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.





















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