TryParseUInt() 공개 정적인 메소드

public static TryParseUInt ( string str, uint &u ) : bool
str string
u uint
리턴 bool
예제 #1
0
        public static uint GetUInt(KeyValuePair <string, string> kvp)
        {
            uint   uValue;
            string str;

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

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

            return(0);
        }
예제 #2
0
        /// <summary>
        /// Get an unsigned 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 integer.</returns>
        /// <exception cref="System.ArgumentNullException">Thrown if <paramref name="strField" />
        /// is <c>null</c>.</exception>
        public static uint GetUInt(string strField, uint uDefaultIfNotFound)
        {
            Debug.Assert(strField != null);
            if (strField == null)
            {
                throw new ArgumentNullException("strField");
            }

            string str;

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

            return(uDefaultIfNotFound);
        }
        internal static void SetEnabled(string strIDs, bool bEnabled)
        {
            if (string.IsNullOrEmpty(strIDs))
            {
                return;
            }

            string[] vIDs = strIDs.Split(new char[] { ',' });
            foreach (string strID in vIDs)
            {
                if (string.IsNullOrEmpty(strID))
                {
                    continue;
                }

                uint uID;
                if (StrUtil.TryParseUInt(strID.Trim(), out uID))
                {
                    SetEnabled(uID, bEnabled);
                }
            }
        }