Do double value calculation in CSharp

Description

The following code shows how to do double value calculation.

Example


using System; //from ww w . j  a  v a 2 s.co  m
 
public class Mars {    
  public static void Main() {    
    double distance = 34000000; // 34,000,000 miles 
    double lightspeed = 186000; // 186,000 per second 
 
    double delay = distance / lightspeed;     
 
    Console.WriteLine("Time delay when talking to Mars: " + 
                      delay + " seconds."); 
     
    double delay_in_min = delay / 60; 
 
    Console.WriteLine("This is " + delay_in_min + 
                      " minutes."); 
  }    
}

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