Convert String to Double Value Or Zero - CSharp System

CSharp examples for System:Double

Description

Convert String to Double Value Or Zero

Demo Code


using System.Text;
using System.IO;//ww  w.java 2 s. c o  m
using System.Globalization;
using System.Collections.Generic;
using System;

public class Main{
        public static double DoubleValueOrZero(this string value)
        {
            double result;
            if (double.TryParse(value, out result))
            {
                return result;
            }
            else
            {
                return 0;
            }

        }
}

Related Tutorials