using System.Net.NetworkInformation;[CSHARP][/CSHARP]

[CSHARP]private void button2_Click(object sender, EventArgs e)
{
string remoteMachineNameOrIP = "127.0.0.1";
int timeOut = 5;
Ping ping = new Ping();
// Pinging remote maching
PingReply reply = ping.Send(remoteMachineNameOrIP, timeOut);
// Displaying the result
StringBuilder sb = new StringBuilder();
sb.Append("Address:" + reply.Address.ToString());
sb.Append("\nStatus:" + reply.Status.ToString());
sb.Append("\nRoundtripTime:" + reply.RoundtripTime.ToString());
MessageBox.Show(sb.ToString(), "Ping Result: " + remoteMachineNameOrIP);
}[/CSHARP]