CSharp examples for System.Xml:XML Attribute
Get As Decimal from XAttribute
using System.Xml.Linq; using System;//from w w w .ja va2s.c o m public class Main{ #endregion #region GetAsDecimal Method public static decimal GetAsDecimal(this XAttribute attr) { decimal ret = 0; decimal value = 0; if (attr != null && !string.IsNullOrEmpty(attr.Value)) { if (decimal.TryParse(attr.Value, out value)) ret = value; } return ret; } }