From 5ed8193971d040d8855ab91f25f7db28cd9e7214 Mon Sep 17 00:00:00 2001 From: Harald Wolff-Thobaben Date: Sat, 10 Jul 2021 01:38:42 +0200 Subject: [PATCH] IPv4: Add implicit casting to System.Net.IPAddress --- ln.type/IPv4.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ln.type/IPv4.cs b/ln.type/IPv4.cs index b6182b8..22da4a0 100644 --- a/ln.type/IPv4.cs +++ b/ln.type/IPv4.cs @@ -1,4 +1,5 @@ using System; +using System.Net; namespace ln.type { @@ -37,7 +38,8 @@ namespace ln.type public static IPv4 operator +(IPv4 ip, int n) => new IPv4((uint)(ip._ip + n)); public static IPv4 operator -(IPv4 ip, int n) => new IPv4((uint)(ip._ip - n)); - - + public static implicit operator IPAddress(IPv4 ipv4) => new IPAddress(ipv4.ToBytes); + public static implicit operator IPv4(IPAddress ipAddress) => new IPv4(ipAddress.GetAddressBytes()); + } } \ No newline at end of file