Parse string to double value in CSharp

Description

The following code shows how to parse string to double value.

Example


//w w  w .  j ava2 s  .c om
using System;
using System.Globalization;

public class MainClass
{
   public static void Main()
   {
        double fromLiteral = -4.987654321E-305;
        double fromParse = Double.Parse("-4.987654321E-305");



        Console.WriteLine("Double value from literal: {0,29:R}", fromLiteral);
        Console.WriteLine("Double value from Parse method: {0,24:R}", fromParse);      
   }
 
}

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