

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C# program to find IP Address of the client
Firstly find the hostname using the Dns.GetHostName() method in C# −
String hostName = string.Empty; hostName = Dns.GetHostName(); Console.WriteLine("Hostname: "+hostName);
Now, use the IPHostEntry.AddressList Property to get IP Address −
IPHostEntry myIP = Dns.GetHostEntry(hostName); IPAddress[] address = myIP.AddressList;
Example
Try the following code to display IP address −
using System; using System.Net; class Program { static void Main() { String hostName = string.Empty; hostName = Dns.GetHostName(); IPHostEntry myIP = Dns.GetHostEntry(hostName); IPAddress[] address = myIP.AddressList; for (int i = 0; i < address.Length; i++) { Console.WriteLine("IP Address {1} : ",address[i].ToString()); } Console.ReadLine(); } }
- Related Questions & Answers
- Java program to find IP Address of the client
- Python program to find the IP Address of the client
- Java program to Get IP address of the system
- C Program to validate an IP address
- JavaScript program to retrieve clients IP address
- Difference between Static IP Address and Dynamic IP Address
- C Program to find IP Address, Subnet Mask & Default Gateway
- Program to find all possible IP address after restoration in C++
- How can we get the client's IP address in ASP.NET MVC C#?
- C# program to Display Hostname and IP address
- Python program to Display Hostname and IP address?
- C Program to display hostname and IP address
- Program to display hostname and IP address C
- Java program to display Hostname and IP address
- Java program to convert Byte array to IP Address
Advertisements