For IPv4, each octet is one byte. You can use System.Net.IPAddress to parse the address and capture an array of bytes, for example:
// parse the address IPAddress ip = IPAddress.Parse("192.168.0.1"); //iterate the byte[] and print each byte foreach(byte i in ip.GetAddressBytes()) { Console.WriteLine(i); }
Code Result:
192 168 0 1
source share