DeviceNetworkInformation.IsNetworkAvailable
// Summary:
// Gets a value that indicates whether the network is available.
//
// Returns:
// true if there is at least one network interface available; otherwise, false.
public static bool IsNetworkAvailable { get; }
NetworkInterface.GetIsNetworkAvailable()
// Summary:
// Indicates whether any network connection is available.
//
// Returns:
// true if a network connection is available; otherwise, false.
[SecuritySafeCritical]
public static bool GetIsNetworkAvailable();
这些相同吗?
答案 0 :(得分:7)
Microsoft wants you to use DeviceNetworkInformation.IsNetworkAvailable
NetworkInterface
位于System.Net
,DeviceNetworkInformation
位于Microsoft.Phone.Net.NetworkInformation
。
DeviceNetworkInformation.IsNetworkAvailable
可能会在内部映射到NetworkInterface.GetIsNetworkAvailable()
,但您应始终使用DeviceNetworkInformation.IsNetworkAvailable
,因为它是为手机制作的(并且具有更清晰的API)。
正如Matthieu所指出的,DeviceNetworkInformation.IsNetworkAvailable
在7.1(芒果)中显然是新的。