/// <summary> /// Occures when Appearance-Mode Notation was changed /// </summary> /// <param name="arg_Value">Value, Input IP-Address notation</param> protected virtual void OnNotationChanged(IPNotation arg_Value) { if (this.NotationChanged != null) this.NotationChanged(arg_Value); }
/// <summary> /// Checks if the given String is an valid ip-address /// </summary> /// <param name="arg_sIP">IP-String</param> /// <param name="arg_ipNotation">IP-notation</param> /// <param name="arg_arlDelimeter">Delimeter to parse IPString</param> /// <returns>true/false validated/not</returns> protected static bool ValidateIP(string arg_sIP, IPNotation arg_ipNotation, ArrayList arg_arlDelimeter) { bool bValidated = false; ArrayList arlIP = new ArrayList(arg_sIP.Split((char[])arg_arlDelimeter.ToArray(typeof(char)))); try { switch (arg_ipNotation) { case IPNotation.IPv4Decimal: case IPNotation.IPv4Binary: bValidated = arlIP.Count == 4; break; case IPNotation.IPv4DecimalCIDR: case IPNotation.IPv4BinaryCIDR: bValidated = arlIP.Count == 5; break; case IPNotation.IPv6Hexadecimal: case IPNotation.IPv6Binary: bValidated = arlIP.Count == 8; break; case IPNotation.IPv6HexadecimalCIDR: case IPNotation.IPv6BinaryCIDR: bValidated = arlIP.Count == 9; break; case IPNotation.IPv6IPv4Decimal: case IPNotation.IPv6IPv4Binary: bValidated = arlIP.Count == 6; break; case IPNotation.IPv6IPv4DecimalCIDR: case IPNotation.IPv6IPv4BinaryCIDR: bValidated = arlIP.Count == 7; break; default: break; } if (!bValidated) { throw new Exception("IP-Address has wrong element count"); } //don't check the 1st 2 elemnt if its IPv4 in IPv6-notation for (int i = (arg_ipNotation.ToString().IndexOf("IPv6IPv4") == 0 ? 2 : 0); //don't check the subnet element i < (arg_ipNotation.ToString().IndexOf("CIDR") > 0 ? arlIP.Count - 1 : arlIP.Count); i++) { string sIPPart = arlIP[i].ToString().Replace(" ", ""); int iIPPart = 0; switch (arg_ipNotation) { case IPNotation.IPv4Decimal: case IPNotation.IPv4DecimalCIDR: case IPNotation.IPv6IPv4Decimal: case IPNotation.IPv6IPv4DecimalCIDR: while (sIPPart.Length < 3) sIPPart = "0" + sIPPart; iIPPart = Convert.ToInt32(sIPPart, 10); if (iIPPart < 256) bValidated = true; else bValidated = false; break; case IPNotation.IPv4Binary: case IPNotation.IPv4BinaryCIDR: case IPNotation.IPv6IPv4Binary: case IPNotation.IPv6IPv4BinaryCIDR: while (sIPPart.Length < 8) sIPPart = "0" + sIPPart; iIPPart = Convert.ToInt32(sIPPart, 2); if (iIPPart < 256) bValidated = true; else bValidated = false; break; case IPNotation.IPv6Hexadecimal: case IPNotation.IPv6HexadecimalCIDR: while (sIPPart.Length < 4) sIPPart = "0" + sIPPart; iIPPart = Convert.ToInt32(sIPPart, 16); if (iIPPart < 65536) bValidated = true; else bValidated = false; break; case IPNotation.IPv6Binary: case IPNotation.IPv6BinaryCIDR: while (sIPPart.Length < 16) sIPPart = "0" + sIPPart; iIPPart = Convert.ToInt32(sIPPart, 2); if (iIPPart < 65536) bValidated = true; else bValidated = false; break; default: break; } if (!bValidated) { throw new Exception(string.Format("IP-Address element {0}({1}) has wrong format", i, sIPPart)); } } } catch (Exception LastError) { System.Diagnostics.Debug.WriteLine(LastError.Message); bValidated = false; throw LastError; } return bValidated; }
/// <summary> /// Creates IP-Addresstring from given StrignArray and Notation /// </summary> /// <param name="arg_sIP">String-Array with elements for IP-Address</param> /// <param name="arg_ipNotation">Notation of IP-Address</param> /// <returns>IPAddress-String</returns> protected static string MakeIP(string[] arg_sIP, IPNotation arg_ipNotation) { string s = ""; for (int i = 0; i < arg_sIP.Length; i++) { switch (arg_ipNotation) { case IPNotation.IPv4Decimal: case IPNotation.IPv4Binary: s += (arg_sIP[i].Length > 0 ? arg_sIP[i] : "0") + (i < (arg_sIP.Length - 1) ? "." : ""); break; case IPNotation.IPv4DecimalCIDR: case IPNotation.IPv4BinaryCIDR: s += (arg_sIP[i].Length > 0 ? arg_sIP[i] : "0") + (i < (arg_sIP.Length - 2) ? "." : (i < arg_sIP.Length - 1) ? "/" : ""); break; case IPNotation.IPv6Hexadecimal: case IPNotation.IPv6Binary: s += arg_sIP[i] + (i < (arg_sIP.Length - 1) ? ":" : ""); break; case IPNotation.IPv6HexadecimalCIDR: case IPNotation.IPv6BinaryCIDR: s += arg_sIP[i] + (i < (arg_sIP.Length - 2) ? ":" : (i < arg_sIP.Length - 1) ? "/" : ""); break; case IPNotation.IPv6IPv4Decimal: case IPNotation.IPv6IPv4Binary: s += (i < 2 ? "" : (arg_sIP[i].Length > 0 ? arg_sIP[i] : "0")) + (i < (arg_sIP.Length - 1) ? (i < 2 ? ":" : ".") : ""); break; case IPNotation.IPv6IPv4DecimalCIDR: case IPNotation.IPv6IPv4BinaryCIDR: s += (i < 2 ? "" : (arg_sIP[i].Length > 0 ? arg_sIP[i] : "0")) + (i < (arg_sIP.Length - 2) ? (i < 2 ? ":" : ".") : (i < arg_sIP.Length - 1) ? "/" : ""); break; default: break; } } return s; }
/// <summary> /// Adds Zeroes to given IP-Address, so it fits in the textfield /// </summary> /// <param name="arg_sIP">IP-String</param> /// <param name="arg_ipNotation">IP-notation</param> /// <param name="arg_arlDelimeter">Delimeter to parse IPString</param> /// <returns>IP-Address with Spaces</returns> protected static string MakeValidZeroes(string arg_sIP, IPNotation arg_ipNotation, ArrayList arg_arlDelimeter) { ArrayList arlIP = new ArrayList(arg_sIP.Split((char[])arg_arlDelimeter.ToArray(typeof(char)))); //don't check the 1st 2 elemnt if its IPv4 in IPv6-notation for (int i = (arg_ipNotation.ToString().IndexOf("IPv6IPv4") == 0 ? 2 : 0); //don't check the subnet element i < (arg_ipNotation.ToString().IndexOf("CIDR") > 0 ? arlIP.Count - 1 : arlIP.Count); i++) { switch (arg_ipNotation) { case IPNotation.IPv4Decimal: case IPNotation.IPv4DecimalCIDR: case IPNotation.IPv6IPv4Decimal: case IPNotation.IPv6IPv4DecimalCIDR: while (arlIP[i].ToString().Length < 3) arlIP[i] = "0" + arlIP[i].ToString(); break; case IPNotation.IPv4Binary: case IPNotation.IPv4BinaryCIDR: case IPNotation.IPv6IPv4Binary: case IPNotation.IPv6IPv4BinaryCIDR: while (arlIP[i].ToString().Length < 8) arlIP[i] = "0" + arlIP[i].ToString(); break; case IPNotation.IPv6Hexadecimal: case IPNotation.IPv6HexadecimalCIDR: while (arlIP[i].ToString().Length < 4) arlIP[i] = "0" + arlIP[i].ToString(); break; case IPNotation.IPv6Binary: case IPNotation.IPv6BinaryCIDR: while (arlIP[i].ToString().Length < 16) arlIP[i] = "0" + arlIP[i].ToString(); break; default: break; } } return IPAddressTextBox.MakeIP((string[])arlIP.ToArray(typeof(string)), arg_ipNotation); }
private void ChangeNotation(IPNotation arg_oldValue, IPNotation arg_newValue) { string sTo = ""; ArrayList arlFrom = new ArrayList(this.Text.Replace(" ", "").Split((char[])this.m_arlDelimeter.ToArray(typeof(char)))); switch (arg_newValue) { case IPNotation.IPv4Decimal: this.m_regexValidNumbers = new Regex("[0-9]"); this.m_arlDelimeter = new ArrayList(new char[] { '.' }); break; case IPNotation.IPv4DecimalCIDR: this.m_regexValidNumbers = new Regex("[0-9]"); this.m_arlDelimeter = new ArrayList(new char[] { '.', '/' }); break; case IPNotation.IPv4Binary: this.m_regexValidNumbers = new Regex("[01]"); this.m_arlDelimeter = new ArrayList(new char[] { '.' }); break; case IPNotation.IPv4BinaryCIDR: this.m_regexValidNumbers = new Regex("[01]"); this.m_arlDelimeter = new ArrayList(new char[] { '.', '/' }); break; case IPNotation.IPv6Hexadecimal: this.m_regexValidNumbers = new Regex("[0-9a-fA-F]"); this.m_arlDelimeter = new ArrayList(new char[] { ':' }); break; case IPNotation.IPv6HexadecimalCIDR: this.m_regexValidNumbers = new Regex("[0-9a-fA-F]"); this.m_arlDelimeter = new ArrayList(new char[] { ':', '/' }); break; case IPNotation.IPv6Binary: this.m_regexValidNumbers = new Regex("[01]"); this.m_arlDelimeter = new ArrayList(new char[] { ':' }); break; case IPNotation.IPv6BinaryCIDR: this.m_regexValidNumbers = new Regex("[01]"); this.m_arlDelimeter = new ArrayList(new char[] { ':', '/' }); break; case IPNotation.IPv6IPv4Decimal: this.m_regexValidNumbers = new Regex("[0-9]"); this.m_arlDelimeter = new ArrayList(new char[] { ':', '.' }); break; case IPNotation.IPv6IPv4DecimalCIDR: this.m_regexValidNumbers = new Regex("[0-9]"); this.m_arlDelimeter = new ArrayList(new char[] { ':', '.', '/' }); break; case IPNotation.IPv6IPv4Binary: this.m_regexValidNumbers = new Regex("[01]"); this.m_arlDelimeter = new ArrayList(new char[] { ':', '.' }); break; case IPNotation.IPv6IPv4BinaryCIDR: this.m_regexValidNumbers = new Regex("[01]"); this.m_arlDelimeter = new ArrayList(new char[] { ':', '.', '/' }); break; default: break; } switch (arg_oldValue) { case IPNotation.IPv4Decimal: switch (arg_newValue) { case IPNotation.IPv4Decimal: break; case IPNotation.IPv4DecimalCIDR: for (int i = 0; i < arlFrom.Count; i++) { sTo += arlFrom[i].ToString() + //Add Slash if its the last IPPart, els add a dot (i == arlFrom.Count - 1 ? "/ " : "."); } break; case IPNotation.IPv4Binary: for (int i = 0; i < arlFrom.Count; i++) { //Convert Decimal to Binary sTo += this.Dec2Bin(arlFrom[i].ToString()) + //Add Dot if its not the last IPPart, else add nothing (i == arlFrom.Count - 1 ? "" : "."); } break; case IPNotation.IPv4BinaryCIDR: for (int i = 0; i < arlFrom.Count; i++) { //Convert Decimal to Binary sTo += this.Dec2Bin(arlFrom[i].ToString()) + //Add Slash if its the last IPPart, else add a dot (i == arlFrom.Count - 1 ? "/ " : "."); } break; case IPNotation.IPv6Hexadecimal: sTo = "0000:0000:0000:0000:"; for (int i = 0; i < arlFrom.Count; i++) { sTo += this.Dec2Hex(arlFrom[i].ToString()) + (i == arlFrom.Count - 1 ? "" : ":"); } break; case IPNotation.IPv6HexadecimalCIDR: sTo = "0000:0000:0000:0000:"; for (int i = 0; i < arlFrom.Count; i++) { sTo += this.Dec2Hex(arlFrom[i].ToString()) + (i == arlFrom.Count - 1 ? "/ " : ":"); } break; case IPNotation.IPv6Binary: sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:"; for (int i = 0; i < arlFrom.Count; i++) { sTo += this.Dec2Bin(arlFrom[i].ToString(), true) + (i == arlFrom.Count - 1 ? "" : ":"); } break; case IPNotation.IPv6BinaryCIDR: sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:"; for (int i = 0; i < arlFrom.Count; i++) { sTo += this.Dec2Bin(arlFrom[i].ToString(), true) + (i == arlFrom.Count - 1 ? "/ " : ":"); } break; case IPNotation.IPv6IPv4Decimal: sTo = "::"; for (int i = 0; i < arlFrom.Count; i++) { sTo += arlFrom[i].ToString() + (i == arlFrom.Count - 1 ? "" : "."); } break; case IPNotation.IPv6IPv4DecimalCIDR: sTo = "::"; for (int i = 0; i < arlFrom.Count; i++) { sTo += arlFrom[i].ToString() + (i == arlFrom.Count - 1 ? "/ " : "."); } break; case IPNotation.IPv6IPv4Binary: sTo = "::"; for (int i = 0; i < arlFrom.Count; i++) { sTo += this.Dec2Bin(arlFrom[i].ToString()) + (i == arlFrom.Count - 1 ? "" : "."); } break; case IPNotation.IPv6IPv4BinaryCIDR: sTo = "::"; for (int i = 0; i < arlFrom.Count; i++) { sTo += this.Dec2Bin(arlFrom[i].ToString()) + (i == arlFrom.Count - 1 ? "/ " : "."); } break; default: break; } break; case IPNotation.IPv4DecimalCIDR: switch (arg_newValue) { case IPNotation.IPv4Decimal: //do not use the last Item, its the Subnetmask for (int i = 0; i < arlFrom.Count - 1; i++) { sTo += arlFrom[i].ToString() + //Add Dot if its not the last IPPart, else add nothing (i == arlFrom.Count - 2 ? "" : "."); } break; case IPNotation.IPv4DecimalCIDR: break; case IPNotation.IPv4Binary: //do not use the last Item, its the Subnetmask for (int i = 0; i < arlFrom.Count - 1; i++) { //Convert Decimal to Binary sTo += this.Dec2Bin(arlFrom[i].ToString()) + //Add Dot if its not the last IPPart, else add nothing (i == arlFrom.Count - 2 ? "" : "."); } break; case IPNotation.IPv4BinaryCIDR: //do not use the last Item, its the Subnetmask for (int i = 0; i < arlFrom.Count - 1; i++) { //Convert Decimal to Binary sTo += this.Dec2Bin(arlFrom[i].ToString()) + //Add Dot if its not the last IPPart, else add nothing (i == arlFrom.Count - 2 ? "" : "."); } //Add Subnetmask sTo += "/" + arlFrom[arlFrom.Count - 1]; break; case IPNotation.IPv6Hexadecimal: sTo = "0000:0000:0000:0000:"; for (int i = 0; i < arlFrom.Count - 1; i++) { sTo += this.Dec2Hex(arlFrom[i].ToString()) + (i == arlFrom.Count - 2 ? "" : ":"); } break; case IPNotation.IPv6HexadecimalCIDR: sTo = "0000:0000:0000:0000:"; for (int i = 0; i < arlFrom.Count - 1; i++) { sTo += this.Dec2Hex(arlFrom[i].ToString()) + (i == arlFrom.Count - 2 ? "" : ":"); } sTo += "/" + arlFrom[arlFrom.Count - 1]; break; case IPNotation.IPv6Binary: sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:"; for (int i = 0; i < arlFrom.Count - 1; i++) { sTo += this.Dec2Bin(arlFrom[i].ToString(), true) + (i == arlFrom.Count - 2 ? "" : ":"); } break; case IPNotation.IPv6BinaryCIDR: sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:"; for (int i = 0; i < arlFrom.Count - 1; i++) { sTo += this.Dec2Bin(arlFrom[i].ToString(), true) + (i == arlFrom.Count - 2 ? "" : ":"); } sTo += "/" + arlFrom[arlFrom.Count - 1]; break; case IPNotation.IPv6IPv4Decimal: sTo = "::"; for (int i = 0; i < arlFrom.Count - 1; i++) { sTo += arlFrom[i].ToString() + (i == arlFrom.Count - 2 ? "" : "."); } break; case IPNotation.IPv6IPv4DecimalCIDR: sTo = "::"; for (int i = 0; i < arlFrom.Count - 1; i++) { sTo += arlFrom[i].ToString() + (i == arlFrom.Count - 2 ? "" : "."); } sTo += "/" + arlFrom[arlFrom.Count - 1]; break; case IPNotation.IPv6IPv4Binary: sTo = "::"; for (int i = 0; i < arlFrom.Count - 1; i++) { sTo += this.Dec2Bin(arlFrom[i].ToString()) + (i == arlFrom.Count - 2 ? "" : "."); } break; case IPNotation.IPv6IPv4BinaryCIDR: sTo = "::"; for (int i = 0; i < arlFrom.Count - 1; i++) { sTo += this.Dec2Bin(arlFrom[i].ToString()) + (i == arlFrom.Count - 2 ? "" : "."); } sTo += "/" + arlFrom[arlFrom.Count - 1]; break; default: break; } break; case IPNotation.IPv4Binary: switch (arg_newValue) { case IPNotation.IPv4Decimal: for (int i = 0; i < arlFrom.Count; i++) { //Convert Binary to Decimal sTo += this.Bin2Dec(arlFrom[i].ToString()) + //Add Dot if its not the last IPPart, else add nothing (i == arlFrom.Count - 1 ? "" : "."); } break; case IPNotation.IPv4DecimalCIDR: for (int i = 0; i < arlFrom.Count; i++) { //Convert Binary to Decimal sTo += this.Bin2Dec(arlFrom[i].ToString()) + //Add Slash if its the last IPPart, els add a dot (i == arlFrom.Count - 1 ? "/ " : "."); } break; case IPNotation.IPv4Binary: break; case IPNotation.IPv4BinaryCIDR: for (int i = 0; i < arlFrom.Count; i++) { sTo += arlFrom[i].ToString() + //Add Slash if its the last IPPart, else add a dot (i == arlFrom.Count - 1 ? "/ " : "."); } break; case IPNotation.IPv6Hexadecimal: sTo = "0000:0000:0000:0000:"; for (int i = 0; i < arlFrom.Count; i++) { sTo += this.Bin2Hex(arlFrom[i].ToString()) + (i == arlFrom.Count - 1 ? "" : ":"); } break; case IPNotation.IPv6HexadecimalCIDR: sTo = "0000:0000:0000:0000:"; for (int i = 0; i < arlFrom.Count; i++) { sTo += this.Bin2Hex(arlFrom[i].ToString()) + (i == arlFrom.Count - 1 ? "/ " : ":"); } break; case IPNotation.IPv6Binary: sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:"; for (int i = 0; i < arlFrom.Count; i++) { sTo += "00000000" + arlFrom[i].ToString() + (i == arlFrom.Count - 1 ? "" : ":"); } break; case IPNotation.IPv6BinaryCIDR: sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:"; for (int i = 0; i < arlFrom.Count; i++) { sTo += "00000000" + arlFrom[i].ToString() + (i == arlFrom.Count - 1 ? "/ " : ":"); } break; case IPNotation.IPv6IPv4Decimal: sTo = "::"; for (int i = 0; i < arlFrom.Count; i++) { sTo += this.Bin2Dec(arlFrom[i].ToString()) + (i == arlFrom.Count - 1 ? "" : "."); } break; case IPNotation.IPv6IPv4DecimalCIDR: sTo = "::"; for (int i = 0; i < arlFrom.Count; i++) { sTo += this.Bin2Dec(arlFrom[i].ToString()) + (i == arlFrom.Count - 1 ? "/ " : "."); } break; case IPNotation.IPv6IPv4Binary: sTo = "::"; for (int i = 0; i < arlFrom.Count; i++) { sTo += arlFrom[i].ToString() + (i == arlFrom.Count - 1 ? "" : "."); } break; case IPNotation.IPv6IPv4BinaryCIDR: sTo = "::"; for (int i = 0; i < arlFrom.Count; i++) { sTo += arlFrom[i].ToString() + (i == arlFrom.Count - 1 ? "/ " : "."); } break; default: break; } break; case IPNotation.IPv4BinaryCIDR: switch (arg_newValue) { case IPNotation.IPv4Decimal: //do not use the last Item, its the Subnetmask for (int i = 0; i < arlFrom.Count - 1; i++) { sTo += this.Bin2Dec(arlFrom[i].ToString()) + //Add Dot if its not the last IPPart, else add nothing (i == arlFrom.Count - 2 ? "" : "."); } break; case IPNotation.IPv4DecimalCIDR: //do not use the last Item, its the Subnetmask for (int i = 0; i < arlFrom.Count - 1; i++) { sTo += this.Bin2Dec(arlFrom[i].ToString()) + //Add Dot if its not the last IPPart, else add nothing (i == arlFrom.Count - 2 ? "" : "."); } //Add Subnetmask sTo += "/" + arlFrom[arlFrom.Count - 1]; break; case IPNotation.IPv4Binary: //do not use the last Item, its the Subnetmask for (int i = 0; i < arlFrom.Count - 1; i++) { sTo += arlFrom[i].ToString() + //Add Dot if its not the last IPPart, else add nothing (i == arlFrom.Count - 2 ? "" : "."); } break; case IPNotation.IPv4BinaryCIDR: break; case IPNotation.IPv6Hexadecimal: sTo = "0000:0000:0000:0000:"; for (int i = 0; i < arlFrom.Count - 1; i++) { sTo += this.Bin2Hex(arlFrom[i].ToString()) + (i == arlFrom.Count - 2 ? "" : ":"); } break; case IPNotation.IPv6HexadecimalCIDR: sTo = "0000:0000:0000:0000:"; for (int i = 0; i < arlFrom.Count - 1; i++) { sTo += this.Bin2Hex(arlFrom[i].ToString()) + (i == arlFrom.Count - 2 ? "" : ":"); } sTo += "/" + arlFrom[arlFrom.Count - 1]; break; case IPNotation.IPv6Binary: sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:"; for (int i = 0; i < arlFrom.Count - 1; i++) { sTo += "00000000" + arlFrom[i].ToString() + (i == arlFrom.Count - 2 ? "" : ":"); } break; case IPNotation.IPv6BinaryCIDR: sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:"; for (int i = 0; i < arlFrom.Count - 1; i++) { sTo += "00000000" + arlFrom[i].ToString() + (i == arlFrom.Count - 2 ? "" : ":"); } sTo += "/" + arlFrom[arlFrom.Count - 1]; break; case IPNotation.IPv6IPv4Decimal: sTo = "::"; for (int i = 0; i < arlFrom.Count - 1; i++) { sTo += this.Bin2Dec(arlFrom[i].ToString()) + (i == arlFrom.Count - 2 ? "" : "."); } break; case IPNotation.IPv6IPv4DecimalCIDR: sTo = "::"; for (int i = 0; i < arlFrom.Count - 1; i++) { sTo += this.Bin2Dec(arlFrom[i].ToString()) + (i == arlFrom.Count - 2 ? "" : "."); } sTo += "/" + arlFrom[arlFrom.Count - 1]; break; case IPNotation.IPv6IPv4Binary: sTo = "::"; for (int i = 0; i < arlFrom.Count - 1; i++) { sTo += arlFrom[i].ToString() + (i == arlFrom.Count - 2 ? "" : "."); } break; case IPNotation.IPv6IPv4BinaryCIDR: sTo = "::"; for (int i = 0; i < arlFrom.Count - 1; i++) { sTo += arlFrom[i].ToString() + (i == arlFrom.Count - 2 ? "" : "."); } sTo += "/" + arlFrom[arlFrom.Count - 1]; break; default: break; } break; case IPNotation.IPv6Hexadecimal: switch (arg_newValue) { case IPNotation.IPv4Decimal: //do not use the 1st 4 elements (IPv4 has only 4 elements) for (int i = 4; i < arlFrom.Count; i++) { //Convert Hexadecimal to Decimal sTo += this.Hex2Dec(arlFrom[i].ToString()) + //Add Dot if its not the last IPPart, else add nothing (i == arlFrom.Count - 1 ? "" : "."); } break; case IPNotation.IPv4DecimalCIDR: //do not use the 1st 4 elements for (int i = 4; i < arlFrom.Count; i++) { sTo += this.Hex2Dec(arlFrom[i].ToString()) + //Add Slash if its the last IPPart, els add a dot (i == arlFrom.Count - 1 ? "/ " : "."); } break; case IPNotation.IPv4Binary: //do not use the 1st 4 elements for (int i = 4; i < arlFrom.Count; i++) { //Convert Hexadecimal to Binary sTo += this.Hex2Bin(arlFrom[i].ToString(), false) + //Add Dot if its not the last IPPart, else add nothing (i == arlFrom.Count - 1 ? "" : "."); } break; case IPNotation.IPv4BinaryCIDR: //do not use the 1st 4 elements for (int i = 4; i < arlFrom.Count; i++) { sTo += this.Hex2Bin(arlFrom[i].ToString(), false) + //Add Slash if its the last IPPart, else add a dot (i == arlFrom.Count - 1 ? "/ " : "."); } break; case IPNotation.IPv6Hexadecimal: break; case IPNotation.IPv6HexadecimalCIDR: for (int i = 0; i < arlFrom.Count; i++) { sTo += arlFrom[i].ToString() + (i == arlFrom.Count - 1 ? "/ " : ":"); } break; case IPNotation.IPv6Binary: for (int i = 0; i < arlFrom.Count; i++) { sTo += this.Hex2Bin(arlFrom[i].ToString()) + (i == arlFrom.Count - 1 ? "" : ":"); } break; case IPNotation.IPv6BinaryCIDR: for (int i = 0; i < arlFrom.Count; i++) { sTo += this.Hex2Bin(arlFrom[i].ToString()) + (i == arlFrom.Count - 1 ? "/ " : ":"); } break; case IPNotation.IPv6IPv4Decimal: sTo = "::"; for (int i = 4; i < arlFrom.Count; i++) { sTo += this.Hex2Dec(arlFrom[i].ToString()) + (i == arlFrom.Count - 1 ? "" : "."); } break; case IPNotation.IPv6IPv4DecimalCIDR: sTo = "::"; for (int i = 4; i < arlFrom.Count; i++) { sTo += this.Hex2Dec(arlFrom[i].ToString()) + (i == arlFrom.Count - 1 ? "/ " : "."); } break; case IPNotation.IPv6IPv4Binary: sTo = "::"; for (int i = 4; i < arlFrom.Count; i++) { sTo += this.Dec2Bin(arlFrom[i].ToString()) + (i == arlFrom.Count - 1 ? "" : "."); } break; case IPNotation.IPv6IPv4BinaryCIDR: sTo = "::"; for (int i = 4; i < arlFrom.Count; i++) { sTo += this.Dec2Bin(arlFrom[i].ToString()) + (i == arlFrom.Count - 1 ? "/ " : "."); } break; default: break; } break; case IPNotation.IPv6HexadecimalCIDR: switch (arg_newValue) { case IPNotation.IPv4Decimal: //do not use the last Item, its the Subnetmask //do not use the 1st 4 elements for (int i = 4; i < arlFrom.Count - 1; i++) { sTo += this.Hex2Dec(arlFrom[i].ToString()) + //Add Dot if its not the last IPPart, else add nothing (i == arlFrom.Count - 2 ? "" : "."); } break; case IPNotation.IPv4DecimalCIDR: //do not use the last Item, its the Subnetmask for (int i = 4; i < arlFrom.Count - 1; i++) { //Convert Hexadecimal to Decimal sTo += this.Hex2Dec(arlFrom[i].ToString()) + //Add Dot if its not the last IPPart, else add nothing (i == arlFrom.Count - 2 ? "" : "."); } //Add Subnetmask sTo += "/" + arlFrom[arlFrom.Count - 1]; break; case IPNotation.IPv4Binary: //do not use the last Item, its the Subnetmask for (int i = 4; i < arlFrom.Count - 1; i++) { sTo += this.Hex2Bin(arlFrom[i].ToString(), false) + //Add Dot if its not the last IPPart, else add nothing (i == arlFrom.Count - 2 ? "" : "."); } break; case IPNotation.IPv4BinaryCIDR: //do not use the last Item, its the Subnetmask for (int i = 4; i < arlFrom.Count - 1; i++) { sTo += this.Hex2Bin(arlFrom[i].ToString(), false) + //Add Dot if its not the last IPPart, else add nothing (i == arlFrom.Count - 2 ? "" : "."); } //Add Subnetmask sTo += "/" + arlFrom[arlFrom.Count - 1]; break; case IPNotation.IPv6Hexadecimal: for (int i = 0; i < arlFrom.Count - 1; i++) { sTo += arlFrom[i].ToString() + (i == arlFrom.Count - 2 ? "" : ":"); } break; case IPNotation.IPv6HexadecimalCIDR: break; case IPNotation.IPv6Binary: for (int i = 0; i < arlFrom.Count - 1; i++) { sTo += this.Hex2Bin(arlFrom[i].ToString()) + (i == arlFrom.Count - 2 ? "" : ":"); } break; case IPNotation.IPv6BinaryCIDR: for (int i = 0; i < arlFrom.Count - 1; i++) { sTo += this.Hex2Bin(arlFrom[i].ToString()) + (i == arlFrom.Count - 2 ? "" : ":"); } sTo += "/" + arlFrom[arlFrom.Count - 1]; break; case IPNotation.IPv6IPv4Decimal: sTo = "::"; for (int i = 4; i < arlFrom.Count - 1; i++) { sTo += this.Hex2Dec(arlFrom[i].ToString()) + (i == arlFrom.Count - 2 ? "" : "."); } break; case IPNotation.IPv6IPv4DecimalCIDR: sTo = "::"; for (int i = 4; i < arlFrom.Count - 1; i++) { sTo += this.Hex2Dec(arlFrom[i].ToString()) + (i == arlFrom.Count - 2 ? "" : "."); } sTo += "/" + arlFrom[arlFrom.Count - 1]; break; case IPNotation.IPv6IPv4Binary: sTo = "::"; for (int i = 4; i < arlFrom.Count - 1; i++) { sTo += this.Dec2Bin(arlFrom[i].ToString()) + (i == arlFrom.Count - 2 ? "" : "."); } break; case IPNotation.IPv6IPv4BinaryCIDR: sTo = "::"; for (int i = 4; i < arlFrom.Count - 1; i++) { sTo += this.Dec2Bin(arlFrom[i].ToString()) + (i == arlFrom.Count - 2 ? "" : "."); } sTo += "/" + arlFrom[arlFrom.Count - 1]; break; default: break; } break; case IPNotation.IPv6Binary: switch (arg_newValue) { case IPNotation.IPv4Decimal: //do not use the 1st 4 elements for (int i = 4; i < arlFrom.Count; i++) { //Convert Binary to Decimal sTo += this.Bin2Dec(arlFrom[i].ToString()) + //Add Dot if its not the last IPPart, else add nothing (i == arlFrom.Count - 1 ? "" : "."); } break; case IPNotation.IPv4DecimalCIDR: //do not use the 1st 4 elements for (int i = 4; i < arlFrom.Count; i++) { sTo += this.Bin2Dec(arlFrom[i].ToString()) + //Add Slash if its the last IPPart, els add a dot (i == arlFrom.Count - 1 ? "/ " : "."); } break; case IPNotation.IPv4Binary: //do not use the 1st 4 elements for (int i = 4; i < arlFrom.Count; i++) { //convert from IPv6 Binary to IPv4 Binary sTo += this.Dec2Bin(this.Bin2Dec(arlFrom[i].ToString())) + //Add Dot if its not the last IPPart, else add nothing (i == arlFrom.Count - 1 ? "" : "."); } break; case IPNotation.IPv4BinaryCIDR: //do not use the 1st 4 elements for (int i = 4; i < arlFrom.Count; i++) { //convert from IPv6 Binary to IPv4 Binary sTo += this.Dec2Bin(this.Bin2Dec(arlFrom[i].ToString())) + //Add Slash if its the last IPPart, else add a dot (i == arlFrom.Count - 1 ? "/ " : "."); } break; case IPNotation.IPv6Hexadecimal: for (int i = 0; i < arlFrom.Count; i++) { sTo += this.Bin2Hex(arlFrom[i].ToString()) + (i == arlFrom.Count - 1 ? "" : ":"); } break; case IPNotation.IPv6HexadecimalCIDR: for (int i = 0; i < arlFrom.Count; i++) { sTo += this.Bin2Hex(arlFrom[i].ToString()) + (i == arlFrom.Count - 1 ? "/ " : ":"); } break; case IPNotation.IPv6Binary: break; case IPNotation.IPv6BinaryCIDR: for (int i = 0; i < arlFrom.Count; i++) { sTo += arlFrom[i].ToString() + (i == arlFrom.Count - 1 ? "/ " : ":"); } break; case IPNotation.IPv6IPv4Decimal: sTo = "::"; for (int i = 4; i < arlFrom.Count; i++) { sTo += this.Bin2Dec(arlFrom[i].ToString()) + (i == arlFrom.Count - 1 ? "" : "."); } break; case IPNotation.IPv6IPv4DecimalCIDR: sTo = "::"; for (int i = 4; i < arlFrom.Count; i++) { sTo += this.Bin2Dec(arlFrom[i].ToString()) + (i == arlFrom.Count - 1 ? "/ " : "."); } break; case IPNotation.IPv6IPv4Binary: sTo = "::"; for (int i = 4; i < arlFrom.Count; i++) { //convert from IPv6 Binary to IPv4 Binary sTo += this.Dec2Bin(this.Bin2Dec(arlFrom[i].ToString())) + (i == arlFrom.Count - 1 ? "" : "."); } break; case IPNotation.IPv6IPv4BinaryCIDR: sTo = "::"; for (int i = 4; i < arlFrom.Count; i++) { //convert from IPv6 Binary to IPv4 Binary sTo += this.Dec2Bin(this.Bin2Dec(arlFrom[i].ToString())) + (i == arlFrom.Count - 1 ? "/ " : "."); } break; default: break; } break; case IPNotation.IPv6BinaryCIDR: switch (arg_newValue) { case IPNotation.IPv4Decimal: //do not use the last Item, its the Subnetmask //do not use the 1st 4 elements for (int i = 4; i < arlFrom.Count - 1; i++) { sTo += this.Bin2Dec(arlFrom[i].ToString()) + //Add Dot if its not the last IPPart, else add nothing (i == arlFrom.Count - 2 ? "" : "."); } break; case IPNotation.IPv4DecimalCIDR: //do not use the last Item, its the Subnetmask for (int i = 4; i < arlFrom.Count - 1; i++) { //Convert Binary to Decimal sTo += this.Bin2Dec(arlFrom[i].ToString()) + //Add Dot if its not the last IPPart, else add nothing (i == arlFrom.Count - 2 ? "" : "."); } //Add Subnetmask sTo += "/" + arlFrom[arlFrom.Count - 1]; break; case IPNotation.IPv4Binary: //do not use the last Item, its the Subnetmask for (int i = 4; i < arlFrom.Count - 1; i++) { //convert from IPv6 Binary to IPv4 Binary sTo += this.Dec2Bin(this.Bin2Dec(arlFrom[i].ToString())) + //Add Dot if its not the last IPPart, else add nothing (i == arlFrom.Count - 2 ? "" : "."); } break; case IPNotation.IPv4BinaryCIDR: //do not use the last Item, its the Subnetmask for (int i = 4; i < arlFrom.Count - 1; i++) { //convert from IPv6 Binary to IPv4 Binary sTo += this.Dec2Bin(this.Bin2Dec(arlFrom[i].ToString())) + //Add Dot if its not the last IPPart, else add nothing (i == arlFrom.Count - 2 ? "" : "."); } //Add Subnetmask sTo += "/" + arlFrom[arlFrom.Count - 1]; break; case IPNotation.IPv6Hexadecimal: for (int i = 0; i < arlFrom.Count - 1; i++) { sTo += this.Bin2Hex(arlFrom[i].ToString()) + (i == arlFrom.Count - 2 ? "" : ":"); } break; case IPNotation.IPv6HexadecimalCIDR: for (int i = 0; i < arlFrom.Count - 1; i++) { sTo += this.Bin2Hex(arlFrom[i].ToString()) + (i == arlFrom.Count - 2 ? "" : ":"); } sTo += "/" + arlFrom[arlFrom.Count - 1]; break; case IPNotation.IPv6Binary: for (int i = 0; i < arlFrom.Count - 1; i++) { sTo += arlFrom[i].ToString() + (i == arlFrom.Count - 2 ? "" : ":"); } break; case IPNotation.IPv6BinaryCIDR: break; case IPNotation.IPv6IPv4Decimal: sTo = "::"; for (int i = 4; i < arlFrom.Count - 1; i++) { sTo += this.Bin2Dec(arlFrom[i].ToString()) + (i == arlFrom.Count - 2 ? "" : "."); } break; case IPNotation.IPv6IPv4DecimalCIDR: sTo = "::"; for (int i = 4; i < arlFrom.Count - 1; i++) { sTo += this.Bin2Dec(arlFrom[i].ToString()) + (i == arlFrom.Count - 2 ? "" : "."); } sTo += "/" + arlFrom[arlFrom.Count - 1]; break; case IPNotation.IPv6IPv4Binary: sTo = "::"; for (int i = 4; i < arlFrom.Count - 1; i++) { //convert from IPv6 Binary to IPv4 Binary sTo += this.Dec2Bin(this.Bin2Dec(arlFrom[i].ToString())) + (i == arlFrom.Count - 2 ? "" : "."); } break; case IPNotation.IPv6IPv4BinaryCIDR: sTo = "::"; for (int i = 4; i < arlFrom.Count - 1; i++) { //convert from IPv6 Binary to IPv4 Binary sTo += this.Dec2Bin(this.Bin2Dec(arlFrom[i].ToString())) + (i == arlFrom.Count - 2 ? "" : "."); } sTo += "/" + arlFrom[arlFrom.Count - 1]; break; default: break; } break; case IPNotation.IPv6IPv4Decimal: switch (arg_newValue) { case IPNotation.IPv4Decimal: //do not use the 1st 2 elements (::) for (int i = 2; i < arlFrom.Count; i++) { sTo += arlFrom[i].ToString() + //Add Dot if its not the last IPPart, else add nothing (i == arlFrom.Count - 1 ? "" : "."); } break; case IPNotation.IPv4DecimalCIDR: //do not use the 1st 2 elements (::) for (int i = 2; i < arlFrom.Count; i++) { sTo += arlFrom[i].ToString() + //Add Slash if its the last IPPart, els add a dot (i == arlFrom.Count - 1 ? "/ " : "."); } break; case IPNotation.IPv4Binary: for (int i = 2; i < arlFrom.Count; i++) { //Convert Decimal to Binary sTo += this.Dec2Bin(arlFrom[i].ToString()) + //Add Dot if its not the last IPPart, else add nothing (i == arlFrom.Count - 1 ? "" : "."); } break; case IPNotation.IPv4BinaryCIDR: for (int i = 2; i < arlFrom.Count; i++) { //Convert Decimal to Binary sTo += this.Dec2Bin(arlFrom[i].ToString()) + //Add Slash if its the last IPPart, else add a dot (i == arlFrom.Count - 1 ? "/ " : "."); } break; case IPNotation.IPv6Hexadecimal: sTo = "0000:0000:0000:0000:"; for (int i = 2; i < arlFrom.Count; i++) { sTo += this.Dec2Hex(arlFrom[i].ToString()) + (i == arlFrom.Count - 1 ? "" : ":"); } break; case IPNotation.IPv6HexadecimalCIDR: sTo = "0000:0000:0000:0000:"; for (int i = 2; i < arlFrom.Count; i++) { sTo += this.Dec2Hex(arlFrom[i].ToString()) + (i == arlFrom.Count - 1 ? "/ " : ":"); } break; case IPNotation.IPv6Binary: sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:"; for (int i = 2; i < arlFrom.Count; i++) { sTo += this.Dec2Bin(arlFrom[i].ToString(), true) + (i == arlFrom.Count - 1 ? "" : ":"); } break; case IPNotation.IPv6BinaryCIDR: sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:"; for (int i = 2; i < arlFrom.Count; i++) { sTo += this.Dec2Bin(arlFrom[i].ToString(), true) + (i == arlFrom.Count - 1 ? "/ " : ":"); } break; case IPNotation.IPv6IPv4Decimal: break; case IPNotation.IPv6IPv4DecimalCIDR: sTo = "::"; for (int i = 2; i < arlFrom.Count; i++) { sTo += arlFrom[i].ToString() + (i == arlFrom.Count - 1 ? "/ " : "."); } break; case IPNotation.IPv6IPv4Binary: sTo = "::"; for (int i = 2; i < arlFrom.Count; i++) { sTo += this.Dec2Bin(arlFrom[i].ToString()) + (i == arlFrom.Count - 1 ? "" : "."); } break; case IPNotation.IPv6IPv4BinaryCIDR: sTo = "::"; for (int i = 2; i < arlFrom.Count; i++) { sTo += this.Dec2Bin(arlFrom[i].ToString()) + (i == arlFrom.Count - 1 ? "/ " : "."); } break; default: break; } break; case IPNotation.IPv6IPv4DecimalCIDR: switch (arg_newValue) { case IPNotation.IPv4Decimal: //do not use the last Item, its the Subnetmask //do not use th2 1st 2 elements for (int i = 2; i < arlFrom.Count - 1; i++) { sTo += arlFrom[i].ToString() + //Add Dot if its not the last IPPart, else add nothing (i == arlFrom.Count - 2 ? "" : "."); } break; case IPNotation.IPv4DecimalCIDR: //do not use the last Item, its the Subnetmask //do not use the 1st 2 Elements for (int i = 2; i < arlFrom.Count - 1; i++) { //Convert Decimal to Binary sTo += arlFrom[i].ToString() + //Add Dot if its not the last IPPart, else add nothing (i == arlFrom.Count - 2 ? "" : "."); } //Add Subnetmask sTo += "/" + arlFrom[arlFrom.Count - 1]; break; case IPNotation.IPv4Binary: //do not use the last Item, its the Subnetmask for (int i = 2; i < arlFrom.Count - 1; i++) { //Convert Decimal to Binary sTo += this.Dec2Bin(arlFrom[i].ToString()) + //Add Dot if its not the last IPPart, else add nothing (i == arlFrom.Count - 2 ? "" : "."); } break; case IPNotation.IPv4BinaryCIDR: //do not use the last Item, its the Subnetmask for (int i = 2; i < arlFrom.Count - 1; i++) { //Convert Decimal to Binary sTo += this.Dec2Bin(arlFrom[i].ToString()) + //Add Dot if its not the last IPPart, else add nothing (i == arlFrom.Count - 2 ? "" : "."); } //Add Subnetmask sTo += "/" + arlFrom[arlFrom.Count - 1]; break; case IPNotation.IPv6Hexadecimal: sTo = "0000:0000:0000:0000:"; for (int i = 2; i < arlFrom.Count - 1; i++) { sTo += this.Dec2Hex(arlFrom[i].ToString()) + (i == arlFrom.Count - 2 ? "" : ":"); } break; case IPNotation.IPv6HexadecimalCIDR: sTo = "0000:0000:0000:0000:"; for (int i = 2; i < arlFrom.Count - 1; i++) { sTo += this.Dec2Hex(arlFrom[i].ToString()) + (i == arlFrom.Count - 2 ? "" : ":"); } sTo += "/" + arlFrom[arlFrom.Count - 1]; break; case IPNotation.IPv6Binary: sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:"; for (int i = 2; i < arlFrom.Count - 1; i++) { sTo += this.Dec2Bin(arlFrom[i].ToString(), true) + (i == arlFrom.Count - 2 ? "" : ":"); } break; case IPNotation.IPv6BinaryCIDR: sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:"; for (int i = 2; i < arlFrom.Count - 1; i++) { sTo += this.Dec2Bin(arlFrom[i].ToString(), true) + (i == arlFrom.Count - 2 ? "" : ":"); } sTo += "/" + arlFrom[arlFrom.Count - 1]; break; case IPNotation.IPv6IPv4Decimal: sTo = "::"; for (int i = 2; i < arlFrom.Count - 1; i++) { sTo += arlFrom[i].ToString() + (i == arlFrom.Count - 2 ? "" : "."); } break; case IPNotation.IPv6IPv4DecimalCIDR: break; case IPNotation.IPv6IPv4Binary: sTo = "::"; for (int i = 2; i < arlFrom.Count - 1; i++) { sTo += this.Dec2Bin(arlFrom[i].ToString()) + (i == arlFrom.Count - 2 ? "" : "."); } break; case IPNotation.IPv6IPv4BinaryCIDR: sTo = "::"; for (int i = 2; i < arlFrom.Count - 1; i++) { sTo += this.Dec2Bin(arlFrom[i].ToString()) + (i == arlFrom.Count - 2 ? "" : "."); } sTo += "/" + arlFrom[arlFrom.Count - 1]; break; default: break; } break; case IPNotation.IPv6IPv4Binary: switch (arg_newValue) { case IPNotation.IPv4Decimal: //do not use the 1st 2 elements (::) for (int i = 2; i < arlFrom.Count; i++) { sTo += this.Bin2Dec(arlFrom[i].ToString()) + //Add Dot if its not the last IPPart, else add nothing (i == arlFrom.Count - 1 ? "" : "."); } break; case IPNotation.IPv4DecimalCIDR: //do not use the 1st 2 elements (::) for (int i = 2; i < arlFrom.Count; i++) { sTo += this.Bin2Dec(arlFrom[i].ToString()) + //Add Slash if its the last IPPart, els add a dot (i == arlFrom.Count - 1 ? "/ " : "."); } break; case IPNotation.IPv4Binary: for (int i = 2; i < arlFrom.Count; i++) { //Convert Decimal to Binary sTo += arlFrom[i].ToString() + //Add Dot if its not the last IPPart, else add nothing (i == arlFrom.Count - 1 ? "" : "."); } break; case IPNotation.IPv4BinaryCIDR: for (int i = 2; i < arlFrom.Count; i++) { //Convert Decimal to Binary sTo += arlFrom[i].ToString() + //Add Slash if its the last IPPart, else add a dot (i == arlFrom.Count - 1 ? "/ " : "."); } break; case IPNotation.IPv6Hexadecimal: sTo = "0000:0000:0000:0000:"; for (int i = 2; i < arlFrom.Count; i++) { sTo += this.Bin2Hex(arlFrom[i].ToString()) + (i == arlFrom.Count - 1 ? "" : ":"); } break; case IPNotation.IPv6HexadecimalCIDR: sTo = "0000:0000:0000:0000:"; for (int i = 2; i < arlFrom.Count; i++) { sTo += this.Bin2Hex(arlFrom[i].ToString()) + (i == arlFrom.Count - 1 ? "/ " : ":"); } break; case IPNotation.IPv6Binary: sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:"; for (int i = 2; i < arlFrom.Count; i++) { sTo += "00000000" + arlFrom[i].ToString() + (i == arlFrom.Count - 1 ? "" : ":"); } break; case IPNotation.IPv6BinaryCIDR: sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:"; for (int i = 2; i < arlFrom.Count; i++) { sTo += "00000000" + arlFrom[i].ToString() + (i == arlFrom.Count - 1 ? "/ " : ":"); } break; case IPNotation.IPv6IPv4Decimal: sTo = "::"; for (int i = 2; i < arlFrom.Count; i++) { sTo += this.Bin2Dec(arlFrom[i].ToString()) + (i == arlFrom.Count - 1 ? "" : "."); } break; case IPNotation.IPv6IPv4DecimalCIDR: sTo = "::"; for (int i = 2; i < arlFrom.Count; i++) { sTo += this.Bin2Dec(arlFrom[i].ToString()) + (i == arlFrom.Count - 1 ? "/ " : "."); } break; case IPNotation.IPv6IPv4Binary: break; case IPNotation.IPv6IPv4BinaryCIDR: sTo = "::"; for (int i = 2; i < arlFrom.Count; i++) { sTo += arlFrom[i].ToString() + (i == arlFrom.Count - 1 ? "/ " : "."); } break; default: break; } break; case IPNotation.IPv6IPv4BinaryCIDR: switch (arg_newValue) { case IPNotation.IPv4Decimal: //do not use the last Item, its the Subnetmask //do not use th2 1st 2 elements for (int i = 2; i < arlFrom.Count - 1; i++) { sTo += this.Bin2Dec(arlFrom[i].ToString()) + //Add Dot if its not the last IPPart, else add nothing (i == arlFrom.Count - 2 ? "" : "."); } break; case IPNotation.IPv4DecimalCIDR: //do not use the last Item, its the Subnetmask //do not use the 1st 2 Elements for (int i = 2; i < arlFrom.Count - 1; i++) { //Convert Decimal to Binary sTo += this.Bin2Dec(arlFrom[i].ToString()) + //Add Dot if its not the last IPPart, else add nothing (i == arlFrom.Count - 2 ? "" : "."); } //Add Subnetmask sTo += "/" + arlFrom[arlFrom.Count - 1]; break; case IPNotation.IPv4Binary: //do not use the last Item, its the Subnetmask for (int i = 2; i < arlFrom.Count - 1; i++) { //Convert Decimal to Binary sTo += arlFrom[i].ToString() + //Add Dot if its not the last IPPart, else add nothing (i == arlFrom.Count - 2 ? "" : "."); } break; case IPNotation.IPv4BinaryCIDR: //do not use the last Item, its the Subnetmask for (int i = 2; i < arlFrom.Count - 1; i++) { //Convert Decimal to Binary sTo += arlFrom[i].ToString() + //Add Dot if its not the last IPPart, else add nothing (i == arlFrom.Count - 2 ? "" : "."); } //Add Subnetmask sTo += "/" + arlFrom[arlFrom.Count - 1]; break; case IPNotation.IPv6Hexadecimal: sTo = "0000:0000:0000:0000:"; for (int i = 2; i < arlFrom.Count - 1; i++) { sTo += this.Bin2Hex(arlFrom[i].ToString()) + (i == arlFrom.Count - 2 ? "" : ":"); } break; case IPNotation.IPv6HexadecimalCIDR: sTo = "0000:0000:0000:0000:"; for (int i = 2; i < arlFrom.Count - 1; i++) { sTo += this.Bin2Hex(arlFrom[i].ToString()) + (i == arlFrom.Count - 2 ? "" : ":"); } sTo += "/" + arlFrom[arlFrom.Count - 1]; break; case IPNotation.IPv6Binary: sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:"; for (int i = 2; i < arlFrom.Count - 1; i++) { sTo += "00000000" + arlFrom[i].ToString() + (i == arlFrom.Count - 2 ? "" : ":"); } break; case IPNotation.IPv6BinaryCIDR: sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:"; for (int i = 2; i < arlFrom.Count - 1; i++) { sTo += "00000000" + arlFrom[i].ToString() + (i == arlFrom.Count - 2 ? "" : ":"); } sTo += "/" + arlFrom[arlFrom.Count - 1]; break; case IPNotation.IPv6IPv4Decimal: sTo = "::"; for (int i = 2; i < arlFrom.Count - 1; i++) { sTo += this.Bin2Dec(arlFrom[i].ToString()) + (i == arlFrom.Count - 2 ? "" : "."); } break; case IPNotation.IPv6IPv4DecimalCIDR: sTo = "::"; for (int i = 2; i < arlFrom.Count - 1; i++) { sTo += this.Bin2Dec(arlFrom[i].ToString()) + (i == arlFrom.Count - 2 ? "" : "."); } sTo += "/" + arlFrom[arlFrom.Count - 1]; break; case IPNotation.IPv6IPv4Binary: sTo = "::"; for (int i = 2; i < arlFrom.Count - 1; i++) { sTo += arlFrom[i].ToString() + (i == arlFrom.Count - 2 ? "" : "."); } break; case IPNotation.IPv6IPv4BinaryCIDR: break; default: break; } break; default: break; } this.Text = sTo; this.MaxLength = this.TextLength; }