diff --git a/X10D/src/Int16Extensions/Int16Extensions.cs b/X10D/src/Int16Extensions/Int16Extensions.cs
index 9348e91..2619b61 100644
--- a/X10D/src/Int16Extensions/Int16Extensions.cs
+++ b/X10D/src/Int16Extensions/Int16Extensions.cs
@@ -1,4 +1,5 @@
-using System;
+using System;
+using System.Net;
namespace X10D
{
@@ -180,5 +181,25 @@ namespace X10D
{
return value != 0;
}
+
+ ///
+ /// Converts an integer value from network byte order to host byte order.
+ ///
+ /// The value to convert, expressed in network byte order.
+ /// An integer value, expressed in host byte order.
+ public static short ToHostOrder(this short value)
+ {
+ return IPAddress.NetworkToHostOrder(value);
+ }
+
+ ///
+ /// Converts an integer value from host byte order to network byte order.
+ ///
+ /// The value to convert, expressed in host byte order.
+ /// An integer value, expressed in network byte order.
+ public static short ToNetworkOrder(this short value)
+ {
+ return IPAddress.HostToNetworkOrder(value);
+ }
}
}
diff --git a/X10D/src/Int32Extensions/Int32Extensions.cs b/X10D/src/Int32Extensions/Int32Extensions.cs
index a2583ab..1316a2c 100644
--- a/X10D/src/Int32Extensions/Int32Extensions.cs
+++ b/X10D/src/Int32Extensions/Int32Extensions.cs
@@ -1,4 +1,5 @@
-using System;
+using System;
+using System.Net;
namespace X10D
{
@@ -180,5 +181,25 @@ namespace X10D
{
return value != 0;
}
+
+ ///
+ /// Converts an integer value from network byte order to host byte order.
+ ///
+ /// The value to convert, expressed in network byte order.
+ /// An integer value, expressed in host byte order.
+ public static int ToHostOrder(this int value)
+ {
+ return IPAddress.NetworkToHostOrder(value);
+ }
+
+ ///
+ /// Converts an integer value from host byte order to network byte order.
+ ///
+ /// The value to convert, expressed in host byte order.
+ /// An integer value, expressed in network byte order.
+ public static int ToNetworkOrder(this int value)
+ {
+ return IPAddress.HostToNetworkOrder(value);
+ }
}
}
diff --git a/X10D/src/Int64Extensions/Int64Extensions.cs b/X10D/src/Int64Extensions/Int64Extensions.cs
index dc1d807..721cc83 100644
--- a/X10D/src/Int64Extensions/Int64Extensions.cs
+++ b/X10D/src/Int64Extensions/Int64Extensions.cs
@@ -1,4 +1,5 @@
-using System;
+using System;
+using System.Net;
namespace X10D
{
@@ -206,5 +207,25 @@ namespace X10D
{
return value != 0;
}
+
+ ///
+ /// Converts an integer value from network byte order to host byte order.
+ ///
+ /// The value to convert, expressed in network byte order.
+ /// An integer value, expressed in host byte order.
+ public static long ToHostOrder(this long value)
+ {
+ return IPAddress.NetworkToHostOrder(value);
+ }
+
+ ///
+ /// Converts an integer value from host byte order to network byte order.
+ ///
+ /// The value to convert, expressed in host byte order.
+ /// An integer value, expressed in network byte order.
+ public static long ToNetworkOrder(this long value)
+ {
+ return IPAddress.HostToNetworkOrder(value);
+ }
}
}