Int32 - HostToNetworkOrder
Converts a short value from host byte order to network byte order.
public static void Main() { Int32 input = 57; // C# Extension Method: Int32 - HostToNetworkOrder Int32 output = input.HostToNetworkOrder(); Console.WriteLine("val = {0}, output = {1}", input, output); }
View Source
using System; using System.Net; public static partial class Extensions { /// <summary> /// Converts an integer value from host byte order to network byte order. /// </summary> /// <param name="host">The number to convert, expressed in host byte order.</param> /// <returns>An integer value, expressed in network byte order.</returns> public static Int32 HostToNetworkOrder(this Int32 host) { return IPAddress.HostToNetworkOrder(host); } }