Windows窗体应用程序-IP统计信息 [英] Windows Form Application - IP Statistics
本文介绍了Windows窗体应用程序-IP统计信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么会出现此错误?
方法"ShowIPStatistics"的无重载采用"0"参数"
我知道它必须有一些参数,但是当我传递参数(NetworkInterfaceComponent)时,它会传递另一条错误消息.
Why I got this error?
"No overload for method ''ShowIPStatistics'' takes ''0'' arguments"
I know it must have some arguments, but when I pass the argument (NetworkInterfaceComponent), it delivers another err message.
using System.Net.NetworkInformation;
namespace WindowsFormsApplication4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
public static void ShowIPStatistics(NetworkInterfaceComponent version)
{
//code for showing IP statistics
}
private void button1_Click(object sender, EventArgs e)
{
ShowIPStatistics();
}
}
}
推荐答案
错误消息说明了所有这些,您必须传递一个参数,因为您已定义了必须将NetworkInterfaceComponent
传递给该方法. br/>
The error message says it all, you have to deliver a parameter, since you have defined thatNetworkInterfaceComponent
must be passed to the method.
private void button1_Click(object sender, EventArgs e)
{
ShowIPStatistics(); //<-- this is causing the problem
}
[添加]
如果您使用的是Visual Studio,请双击错误将您带到问题所在的地方.
[Addition]
If you''re using Visual Studio, double clicking the error takes you to the place where the problem is.
好吧,因为您在没有任何调用的情况下调用了ShowIPStatistics()
参数.
Well you are getting it because you make a call toShowIPStatistics()
without any parameters.
private void button1_Click(object sender, EventArgs e)
{
ShowIPStatistics(); // <<<<<============= HERE ======================
}
您必须传递NetworkInterfaceComponent
.这是您的方法,您应该知道!
You have to pass in a NetworkInterfaceComponent
. It''s your method, you should know that!
NetworkInterfaceComponent
是一个枚举.它有两个可能的值IPv4或IPv6.
因此,您必须使用以下任一方法:
TheNetworkInterfaceComponent
is an enumeration. It has two possible values IPv4 or IPv6.
Therefore you have to use either:
private void button1_Click(object sender, EventArgs e)
{
ShowIPStatistics(NetworkInterfaceComponent.IPv4);
}
或:
or:
private void button1_Click(object sender, EventArgs e)
{
ShowIPStatistics(NetworkInterfaceComponent.IPv6);
}
这篇关于Windows窗体应用程序-IP统计信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文