TryParseULong() public static method

public static TryParseULong ( string str, ulong &u ) : bool
str string
u ulong
return bool
示例#1
0
        public static ulong GetULong(KeyValuePair <string, string> kvp)
        {
            ulong  uValue;
            string str;

            if (m_cfgCurrent.TryGetValue(kvp.Key, out str))
            {
                if (StrUtil.TryParseULong(str, out uValue))
                {
                    return(uValue);
                }
                else
                {
                    Debug.Assert(false);
                }
            }

            if (StrUtil.TryParseULong(kvp.Value, out uValue))
            {
                return(uValue);
            }
            else
            {
                Debug.Assert(false);
            }

            return(0);
        }
示例#2
0
        /// <summary>
        /// Get an unsigned long integer value from the current configuration.
        /// </summary>
        /// <param name="strField">Name of the configuration item.</param>
        /// <param name="uDefaultIfNotFound">Default value that is returned if
        /// the specified item cannot be found.</param>
        /// <returns>An unsigned long integer.</returns>
        /// <exception cref="System.ArgumentNullException">Thrown if <paramref name="strField" />
        /// is <c>null</c>.</exception>
        public static ulong GetULong(string strField, ulong uDefaultIfNotFound)
        {
            Debug.Assert(strField != null);
            if (strField == null)
            {
                throw new ArgumentNullException("strField");
            }

            string str;

            if (m_cfgCurrent.TryGetValue(strField, out str))
            {
                ulong uValue;
                if (StrUtil.TryParseULong(str, out uValue))
                {
                    return(uValue);
                }
            }

            return(uDefaultIfNotFound);
        }