C# has a new feature for you to ping your endpoint programmatically using the Ping class from System.Net.NetworkInformation library.
How to get installed System.Net.NetworkInformation?
Go to NuGet Package Manager, search “System.Net.NetWorkInformation” and install it.
Tools -> NuGet Package Manager -> Manage NuGet Package for Solution…
Or
Right click on Project in Solution Explorer and choose “Manage NuGet Packages..”

Example Code
static void Main(string[] args)
{
string YourEndPoint = "www.codewithsiva.com";
Ping pingyourendpoint = new Ping();
PingReply ping = pingyourendpoint.Send(YourEndPoint);
if (ping.Status == IPStatus.Success)
{
Console.WriteLine($"Ping to {YourEndPoint} was successfuly.");
Console.WriteLine($"IP Address: {ping.Address}");
Console.WriteLine($"Round Trip Time: {ping.RoundtripTime} milliseconds");
Console.WriteLine($"Time to live: {ping.Options.Ttl}");
Console.WriteLine($"Don't Fragment: {ping.Options.DontFragment}");
Console.WriteLine($"Buffer: {ping.Buffer.Length}");
}
else
Console.WriteLine($"Ping to {YourEndPoint} failed with status: {ping.Status}");
}
C#Output:
