TryParseUShort() public static méthode

public static TryParseUShort ( string str, ushort &u ) : bool
str string
u ushort
Résultat bool
Exemple #1
0
		public static ulong ParseVersion(string strVersion)
		{
			if(strVersion == null) { Debug.Assert(false); return 0; }

			string[] vVer = strVersion.Split(m_vVersionSep);
			if((vVer == null) || (vVer.Length == 0)) { Debug.Assert(false); return 0; }

			ushort uPart;
			StrUtil.TryParseUShort(vVer[0].Trim(), out uPart);
			ulong uVer = ((ulong)uPart << 48);

			if(vVer.Length >= 2)
			{
				StrUtil.TryParseUShort(vVer[1].Trim(), out uPart);
				uVer |= ((ulong)uPart << 32);
			}

			if(vVer.Length >= 3)
			{
				StrUtil.TryParseUShort(vVer[2].Trim(), out uPart);
				uVer |= ((ulong)uPart << 16);
			}

			if(vVer.Length >= 4)
			{
				StrUtil.TryParseUShort(vVer[3].Trim(), out uPart);
				uVer |= (ulong)uPart;
			}

			return uVer;
		}
Exemple #2
0
        public static ulong GetVersion(string strVersion)
        {
            if (string.IsNullOrEmpty(strVersion))
            {
                Debug.Assert(false); return(0);
            }

            string[] vVer = strVersion.Split(new char[] { '.', ',' });
            if ((vVer == null) || (vVer.Length == 0))
            {
                Debug.Assert(false); return(0);
            }

            ushort uPart;

            StrUtil.TryParseUShort(vVer[0], out uPart);
            ulong uVer = ((ulong)uPart << 48);

            if (vVer.Length >= 2)
            {
                StrUtil.TryParseUShort(vVer[1], out uPart);
                uVer |= ((ulong)uPart << 32);
            }

            if (vVer.Length >= 3)
            {
                StrUtil.TryParseUShort(vVer[2], out uPart);
                uVer |= ((ulong)uPart << 16);
            }

            if (vVer.Length >= 4)
            {
                StrUtil.TryParseUShort(vVer[3], out uPart);
                uVer |= (ulong)uPart;
            }

            return(uVer);
        }