C# IPAddress GetAddressBytes

Description

IPAddress GetAddressBytes Provides a copy of the IPAddress as an array of bytes.

Syntax

IPAddress.GetAddressBytes has the following syntax.


public byte[] GetAddressBytes()

Returns

IPAddress.GetAddressBytes method returns

Example

The following code example shows how to get a server IP address in byte format.


using System;//w w w.j  a  v  a 2s  .  c  o m
using System.Net;
using System.Net.Sockets;

public class Example
{
   public static void Main()
   {
        IPAddress address = new IPAddress(0x2112188f);
        Byte[] bytes = address.GetAddressBytes();
        for (int i = 0; i < bytes.Length; i++) 
        {
          Console.Write(bytes[i]);
        }
   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Net »




Cookie
Dns
IPAddress
IPEndPoint
IPHostEntry
WebClient