BoardGameGeekApiClient.Helpers.BoardGameGeekApiClientHelper.GetDecimalValue C# (CSharp) Method

GetDecimalValue() public static method

public static GetDecimalValue ( this element, string attribute = null, decimal defaultValue = null ) : decimal?
element this
attribute string
defaultValue decimal
return decimal?
        public static decimal? GetDecimalValue(this XElement element, string attribute = null, decimal? defaultValue = null)
        {
            var val = GetStringValue(element, attribute, null);
            if (string.IsNullOrEmpty(val))
                return defaultValue;

            decimal retVal;
            if (!decimal.TryParse(val, NumberStyles.Any, new CultureInfo("en-US"), out retVal))
                return defaultValue;
            return retVal;
        }