How to Ping an IP Address in .NET

You have an IP Address and you want to ping it using your application you can use Ping class.

First of all import System.Net.NetworkInformation namespace

using System.Net.NetworkInformation;​

Then use Send method of Ping class to ping an IP as shown below:

Ping ping = new Ping();
PingReply pingReply = ping.Send("");

Console.WriteLine("Address: {0}", pingReply.Address);
Console.WriteLine("Time in miliseconds: {0}", pingReply.RoundtripTime);
Console.WriteLine("Status: {0}", pingReply.Status);​



About author

User avatar

Waqas Anwar

Founder of, Senior Consultant, Microsoft .NET and Web Technologies