Get As Double - CSharp System.Xml

CSharp examples for System.Xml:XML Attribute

Description

Get As Double

Demo Code


using System.Xml.Linq;
using System;/*  www .j a va  2  s.  c o m*/

public class Main{
        #endregion

        #region GetAsDouble Method
        public static double GetAsDouble(this XAttribute attr)
        {
            double ret = 0;
            double value = 0;

            if (attr != null && !string.IsNullOrEmpty(attr.Value))
            {
                if (double.TryParse(attr.Value, out value))
                    ret = value;
            }

            return ret;
        }
}

Related Tutorials