Declare a method to handle NetworkAvailabilityChanged events : NetworkChange « Network « C# / CSharp Tutorial






using System;
using System.Net.NetworkInformation;

class MainClass
{
    
    private static void NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
    {
        if (e.IsAvailable)
        {
            Console.WriteLine("Network Available");
        }
        else
        {
            Console.WriteLine("Network Unavailable");
        }
    }

    static void Main(string[] args)
    {
        NetworkChange.NetworkAvailabilityChanged +=  NetworkAvailabilityChanged;
    }
}








33.33.NetworkChange
33.33.1.Declare a method to handle NetworkAvailabilityChanged events
33.33.2.Declare a method to handle NetworkAdressChanged events