Convert String To Double - CSharp System

CSharp examples for System:Converter

Description

Convert String To Double

Demo Code


using System.Threading.Tasks;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;/*  w  ww  .ja v  a  2s .c om*/

public class Main{
        public static double ConvertStringToDouble(string value)
        {
            double doubleValue;

            bool IsValid = Double.TryParse(value, out doubleValue);
            if (IsValid == false)
            {
                throw new Exception("String is not in the right format - Double");
            }
            return doubleValue;
        }
}

Related Tutorials