C# IPAddress from string

C#StringIp Address

C# Problem Overview


I need to define the IP address in the class System.Net.IPAddress but the method:

IPAddress ipaddress = IPAddress.Parse("127.0.0.1");  //127.0.0.1 as an example

doesn't work, is there another method?

How can I define the IP address?

C# Solutions


Solution 1 - C#

You've probably miss-typed something above that bit of code or created your own class called IPAddress. If you're using the .net one, that function should be available.

Have you tried using System.Net.IPAddress just in case?

System.Net.IPAddress ipaddress = System.Net.IPAddress.Parse("127.0.0.1");  //127.0.0.1 as an example

The docs on Microsoft's site have a complete example which works fine on my machine.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionPatrick LorioView Question on Stackoverflow
Solution 1 - C#Jon CageView Answer on Stackoverflow