Using system; using system. collections. generic; using system. LINQ; using system. net; using system. windows; using system. windows. controls; using system. windows. documents; using system. windows. input; using system. windows. media; using system. windows. media. animation; using system. windows. shapes; using Microsoft. phone. controls; using system. net. networkinformation; using Microsoft. phone. net. networkinformation; namespace checknet {public partial class mainpage: phoneapplicationpage {private bool networkisavailable; private networkinterfacetype _ currentnetworktype; // public mainpage () {initializecomponent ();} private void button#click (Object sender, routedeventargs e) {networkisavailable = Microsoft. phone. net. networkinformation. networkinterface. getisnetworkavailable (); // whether the current network is available _ currentnetworktype = Microsoft. phone. net. networkinformation. networkinterface. networkinterfacetype; // obtain the current network type if (networkisavailable) {message. TEXT = "Networking status"; message. background = new solidcolorbrush (colors. green);} else {message. TEXT = "disconnected"; message. background = new solidcolorbrush (colors. red);} switch (_ currentnetworktype) {Case networkinterfacetype. mobilebroadbandcdma: netname. TEXT = "CDMA network"; break; Case networkinterfacetype. mobilebroadbandgsm: netname. TEXT = "csm network"; break; Case networkinterfacetype. wireless80211: netname. TEXT = "wireless network"; break; Case networkinterfacetype. ethernet: netname. TEXT = "Ethernet network"; break; Case networkinterfacetype. none: netname. TEXT = "Network unavailable"; break; default: netname. TEXT = "other networks"; break ;}}}}