Convert String value to Decimal Value Or Zero - CSharp System

CSharp examples for System:Decimal

Description

Convert String value to Decimal Value Or Zero

Demo Code


using System.Text;
using System.IO;/*  w ww .jav  a2 s.c  o  m*/
using System.Globalization;
using System.Collections.Generic;
using System;

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

        }
}

Related Tutorials