Click here to Skip to main content
15,889,281 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
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();
        }
    }
}
Posted
Updated 26-Mar-11 9:54am
v4
Comments
Sergey Alexandrovich Kryukov 26-Mar-11 15:22pm    
OP commented:

first of all, thanks a lot for your timely and dynamic response Smile | :)

but when i passing the parameter, it delivers another error

"System.Net.NetworkInformation.NetworkInterfaceComponent is a 'type but it is used like a 'variable' "

Collapse

private void button1_Click(object sender, EventArgs e)
{
ShowIPStatistics(NetworkInterfaceComponent);
}
Sergey Alexandrovich Kryukov 26-Mar-11 15:26pm    
OK. I see what's going on. You're passing a type, but should pass a variable.
If looks like you don't understand the difference well. At this moment, you're not ready to do any programming. Please go back to your language/programming manuals and learn.
If you keep asking such questions here, you won't get effective help: answers cannot replace some learning.
Please do what I advise, there is nothing better or "easier".
--SA
Sergey Alexandrovich Kryukov 26-Mar-11 18:50pm    
@itsnitro: I received accusation from nitinmurali that I did not answer "his/her" question.
Do you know anything about it?
And pay attention: I answered your second question above.
--SA

The error message says it all, you have to deliver a parameter, since you have defined that NetworkInterfaceComponent must be passed to the method.
C#
private void button1_Click(object sender, EventArgs e)
{
    ShowIPStatistics(); //<-- this is causing the problem
}


[Addition]
If you're using Visual Studio, double clicking the error takes you to the place where the problem is.
 
Share this answer
 
v3
Comments
Sergey Alexandrovich Kryukov 26-Mar-11 15:27pm    
We have three nearly simultaneous answers. My 5, but there is no use: see follow-up Question on top and my comment.
--SA
Well you are getting it because you make a call to ShowIPStatistics() without any parameters.
C#
private void button1_Click(object sender, EventArgs e)
{
    ShowIPStatistics();  // <<<<<============= HERE ======================
}


You have to pass in a NetworkInterfaceComponent. It's your method, you should know that!
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 26-Mar-11 15:27pm    
We have three nearly simultaneous answers. My 5, but there is no use: see follow-up Question on top and my comment.
--SA
The NetworkInterfaceComponent is an enumeration. It has two possible values IPv4 or IPv6.

Therefore you have to use either:
C#
private void button1_Click(object sender, EventArgs e)
{
    ShowIPStatistics(NetworkInterfaceComponent.IPv4);
}

or:
C#
private void button1_Click(object sender, EventArgs e)
{
    ShowIPStatistics(NetworkInterfaceComponent.IPv6);
}
 
Share this answer
 
Read error message; there is nothing to explain beyond that.

Requires one argument:
C#
public static void ShowIPStatistics(NetworkInterfaceComponent version)


Attempted to call without argument:
C#
ShowIPStatistics();


There are no more (overloaded) methods with this name.

A follow-up Question was answered in comment.

—SA
 
Share this answer
 
v2
Comments
Wendelius 26-Mar-11 15:36pm    
:) 5'd. If your interested, have a look: http://www.codeproject.com/Lounge.aspx?msg=3830674#xx3830674xx
Sergey Alexandrovich Kryukov 26-Mar-11 15:52pm    
Funny. OK, another bunch of idiots. But I would understand looking at real-life programmers. I have a feeling that the rule "we do not hire programmers" would work better, if a programmer is somebody with the programming diploma. As I noticed, most people are absolutely unable to program, but they do. It's more likely to find a person without this disability, it this person has a non-programming diploma. This is my impression. Most decent software developers I know have some more "real" education.
--SA
Sergey Alexandrovich Kryukov 26-Mar-11 15:54pm    
Thanks for the vote.
I finally decided to put another answer -- to a follow-up Question. Please see: it's something funny to continue our discussion...
--SA
Sergey Alexandrovich Kryukov 26-Mar-11 18:46pm    
I can be proud: This Answer is the only one which got a vote of "1". If my answers irritate the idiots, I must be doing something right!
--SA
Stop posting anything as Answer!
Stop repeating Questions!

I already answered your follow-up Question: you're trying to pass a type instead of variable.
Nobody will explain you the difference is short terms. You need to learn at least most basic ideas of programming. You cannot develop anything before you do.

Take a manual and learn something!
You're not yet ready to ask questions here at CodeProject the way you can get effective help!

Read this:
I have a problem with my program. Please help![^]

This is the basic technique to learn:
Microsoft Q209354

This is just for sobering:
http://norvig.com/21-days.html[^]

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900