Simple internet checker C#

I search all trough the internet.

does anyone know how to do a simple internet checker??
(if has internet or not)

or

what you send is not c# and not simple

using UnityEngine;
using System.Collections;

public class NetAvailable : MonoBehaviour
{

    void Start()
    {
        if(Method1())
        {
            Debug.Log("HAS INTERNET ACCESS");
        }
        else
        {
            Debug.Log("NO INTERNET ACCESS");
        }
    }

    bool Method1()
    {
        if (Application.internetReachability == NetworkReachability.ReachableViaLocalAreaNetwork)
            return true;
        return false;
    }

    //Pauses thread
    bool Method2()
    {
        try
        {
            System.Net.Dns.GetHostEntry("www.google.com");
            return true;
        }
        catch
        {
            return false;
        }
    }

}
1 Like

hey thanks for the help!