コード例 #1
0
        public Ipv4Address(string dottedDecimal)
        {
            uint offset = 0;

            value = GlobalMembers.readUint8(dottedDecimal, ref offset);
            if (offset == dottedDecimal.Length || dottedDecimal[offset] != '.')
            {
                throw new System.Exception("Invalid Ipv4 address string");
            }

            ++offset;
            value = value << 8 | GlobalMembers.readUint8(dottedDecimal, ref offset);
            if (offset == dottedDecimal.Length || dottedDecimal[offset] != '.')
            {
                throw new System.Exception("Invalid Ipv4 address string");
            }

            ++offset;
            value = value << 8 | GlobalMembers.readUint8(dottedDecimal, ref offset);
            if (offset == dottedDecimal.Length || dottedDecimal[offset] != '.')
            {
                throw new System.Exception("Invalid Ipv4 address string");
            }

            ++offset;
            value = value << 8 | GlobalMembers.readUint8(dottedDecimal, ref offset);
            if (offset < dottedDecimal.Length)
            {
                throw new System.Exception("Invalid Ipv4 address string");
            }
        }