単純にこれを行うことができないことがわかったとき、私は本当に驚きました:
Dim ip = IPAddress.Parse("192.168.1.3")
Dim mask = IPAddress.Parse("255.255.255.0")
' next lines won't compile
Dim networkAddress = ip And mask ' would produce 192.168.1.0
Dim broadcastAddress = ip Or (Not mask) ' would produce 192.168.1.255
したがって、このタイプの機能を自分でサブクラスに実装する前に、明らかな何かが欠けているのでしょうか? 私が見落としているこれが実装されなかった理由はありますか?
ネットワーキングの授業中に、おそらく注意を払うべきほど注意を払っていなかったかもしれないことは認めます。
編集
私はこのコードブロックを思いつきました:
Dim ip = IPAddress.Parse("192.168.1.3")
Dim mask = IPAddress.Parse("255.255.255.0")
Dim ipUnsignedInteger = BitConverter.ToUInt32(ip.GetAddressBytes, 0)
Dim maskUnsignedInteger = BitConverter.ToUInt32(mask.GetAddressBytes, 0)
Dim networkAddressUnsignedInteger = ipUnsignedInteger And maskUnsignedInteger
Dim networkAddress = New IPAddress(networkAddressUnsignedInteger)
Dim broadcastAddressUnsignedInteger = ipUnsignedInteger Or (Not maskUnsignedInteger)
Dim broadcastAddress = New IPAddress(broadcastAddressUnsignedInteger)
それは機能しますが、私には明らかなように見えるものに対して、信じられないほどの量の余分なコードです! なぜこれがフレームワークの一部ではないのですか?!