Question "No overload for method" Error

jcw608

New member
Joined
Oct 28, 2017
Messages
1
Location
Texas
Programming Experience
Beginner
Maybe someone can help me with this code. I am just learning c# and i could use all the help i can get. In the NPC.cs file on line 13 I get the error "No overload for method 'AddNewDialogue' takes '1' arguments". I have been fighting this line of code for hours! If anyone can take a look at the attached files and help, it would be much appreciated. Thank you!
 

Attachments

  • Project.zip
    3.6 KB · Views: 38
Please do not post your entire project as a first option. Post the relevant code and only the relevant code directly, using appropriate formatting tags, i.e.

[xcode=c#]your code here[/xcode]

If we can't work out the issue form that, then we'll let you know if we need the entire project. It should be a last resort. You should also provide a FULL and CLEAR explanation of the problem. Don't expect us to infer everything from the code, especially if it has not been adequately commented (which I don't is or is not the case here because I haven't looked).

That said, the error message is quite clear. You're calling a method named AddNewDialogue and you're only passing one argument, but there is no such method with only one parameter. You can only pass to a method what it expects to receive. When you type the name of a method and an opening parenthesis, Intellisense will pop up a list of all the overloads the method has and what parameters each one has. You must provide arguments for the parameters of one of those overloads and nothing more.

Did you write that AddNewDialogue method yourself? If not, you should probably read the documentation for it to see what it does and what each parameter means. If you did write it yourself then you have obviously not written it in the way that you want to be able to use it, so you need to change it accordingly. Please post ONLY the method if it is your own and also the section of code where you're calling it and provide an explanation of what it is supposed to do and what each parameter represents and why you're trying to pass it something different to what it expects.
 
As an example, consider this method:
public void DoSomething()
{
    // ...
}

public void DoSomething(string text, int number)
{
    // ...
}

That method is overloaded, i.e. has multiple implementations with different signatures. One overload has no parameters and the other has two parameters, so it must be called with no arguments or two arguments. If you were to call that method and pass one argument you would get the same error message as you're seeing because there is no overload that takes one argument.
 
Back
Top Bottom