我有这个方法:
public static void testConnection()
{
if (System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable())
{
System.Windows.MessageBox.Show("This computer is connected to the internet");
}
else
{
System.Windows.MessageBox.Show("This computer is not connected to the internet");
}
}
我想它会告诉我连接是否可用,但即使我确定没有连接,它也总是返回 true(并打印第一条消息)。我做错了什么?
PS:我还在学习C#。