Sometimes we require to check whether the network is available or not, normally when are trying to do an Updated version check from our application or invoking a third party web service or any looking for any licence information / registration details from website etc.
This is a simple function which will return Network status using Ping Class.
using System.Net.NetworkInformation;
public bool IsNetworkAvailable()
{
using (Ping ping = new Ping())
{
PingReply pingReply = ping.Send("www.google.com", 200);
return pingReply.Status == IPStatus.Success;
}
}