Checking Network Connectivity of your PC

Introduction
 
Using help of NetworkInterface class of System.Net.NetworkInformation the internet connection can be detected. see the code below for more details
 
Code
 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace MyCRND

{

    class Program

    {

        static void Main(string[] args)

        {

            Console.WriteLine((System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable() == true ? "Connected" : "Not Connected"));

            Console.ReadLine();

        }

    }

}

Ebook Download
View all
Learn
View all