Get As Long - CSharp System.Xml

CSharp examples for System.Xml:XML Attribute

Description

Get As Long

Demo Code


using System.Xml.Linq;
using System;//  w w  w .  ja  v  a  2s.  c  o m

public class Main{
        #endregion

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

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

            return ret;
        }
}

Related Tutorials