Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
System.Net.IPAddress constructor
Message
General information
Forum:
ASP.NET
Category:
Other
Title:
System.Net.IPAddress constructor
Miscellaneous
Thread ID:
00985599
Message ID:
00985599
Views:
83
I can't figure out why this code throws an error:
System.Byte[] ba = {127,0,0,1};
System.Net.IPAddress ip = new System.Net.IPAddress(ba);
The 2nd line in the code above throws the following error:
System.ArgumentException: address
This is what the M$ docs say about one of the overloaded constructor for this class:
Initializes a new instance of the IPAddress class with the specified address and scope equal to 0.

public IPAddress( byte[] address);


Parameters
address 
The byte array value of the IP address. 
And the funny thing is that no exceptions are listed in the M$ Docs for this constructor.

Any help would be appreciated.

UPDATE:
The following code does work, but I would still like to know why the code above does not work:
StringBuilder sbIP = new StringBuilder(15);
sbIP.Append(baGeneralStatusPacket[258].ToString());
sbIP.Append('.');
sbIP.Append(baGeneralStatusPacket[259].ToString());
sbIP.Append('.');
sbIP.Append(baGeneralStatusPacket[260].ToString());
sbIP.Append('.');
sbIP.Append(baGeneralStatusPacket[261].ToString());

this._IPAddress = IPAddress.Parse(sbIP.ToString());
Einar
Semper ubi sub ubi.
Next
Reply
Map
View

Click here to load this message in the networking platform