How it works...

In steps 1 to 11, we added a blank solution and added a .NET Standard 2.0 class library to the solution. In these steps, we have given proper names to the solution and the project. Then, in step 12 we changed the name of the default Class1.cs generated from Visual Studio. In step 15, we added the required using directive to the code. We have mainly used System.Net and System.Net.Sockets to access the required classes and read the IP address, and then added the System.Collecitons.Generic namespace to create a generic string List to hold the IP addresses.

In step 16, we added a public method that will read all the available IP addresses of the local machine you are on. In the first line, we stored the host name of the system in a variable and in the second line we used it to get the host addresses. Then, we created an empty list to store the IP addresses.

After that, we used a foreach loop to go through all the IP addresses we found and store them in the list after checking whether it was an IP address on the internal network. Finally, we returned the list of IP addresses we stored.

In step 17, we did a quick build to check syntax.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.178.133