String As Decimal - CSharp System

CSharp examples for System:String Number

Description

String As Decimal

Demo Code


using System;//from  www  .  j  av a  2 s . c o  m

public class Main{
        public
        static
        Decimal
        AsDecimal(
            this string str,
            Decimal defaultValue = default(Decimal))
        {
            Decimal value;

            return Decimal.TryParse(str, out value)
                        ? value
                        : defaultValue;
        }
}

Related Tutorials