using System; using System.Net; class Example { static void Main() { IPEndPoint endPoint = new IPEndPoint(IPAddress.Parse("10.0.0.1"), 8080); byte[] serializedEndPoint = endPoint.Serialize(); Console.WriteLine(BitConverter.ToString(serializedEndPoint)); } }
using System; using System.Net; class Example { static void Main() { byte[] serializedEndPoint = new byte[] { 10, 0, 0, 1, 31, 128 }; IPEndPoint endPoint = new IPEndPoint(IPAddress.Any, 0); endPoint.Deserialize(serializedEndPoint); Console.WriteLine(endPoint); } }In this example, we create a byte array containing the serialized endpoint information obtained from Example 1. We then create a new IPEndPoint object with any IP address and port number 0, and call the Deserialize method to deserialize the endpoint information into the object. Finally, we display the endpoint object using the Console.WriteLine method. This functionality is part of the System.Net.Sockets package library.