Getting error CS1061 - Please help

hi guys , im making a hangman game but get 1 last error which is CS1061 the following pastebin link is my code , can anyone help me out please? Thanks

Thanks for your time.

Can you post a little more information about the error you are getting? I don't know what error code that represents and information, like what line the error occurs on, will help.

That error number is for " does not exist" so he tried to call something that doesn't exist. OP: You should provide a line number that it happens on. In fact, if you double click the error, it takes you directly to the line that failed.

Agreed the exact line would be good. Just a guess but did you put any values in your word array?

1 Answer

1

The compiler will tell you the exact line that has the problem. Look for two numbers inside round brackets. You need the first of these numbers. This is the line with the problem. Next time you need help, it’ll make it far easier to help you if give the line number, or comment you code with something that says //<---- error here. If you are feeling daring, you could always double-click the error in Unity and Unity will open MonoDevelop and drop the cursor onto the line that has the problem. This is the way the rest of us solve these kinds of problems.

Anyway, because I am a decent helpful chap, I just copied and pasted your code into my Unity project. I got the following, which, is exactly what I expect you’ll get:

Assets/Hangman.cs(32,33): error CS0103: The name `checkChar' does not exist in the current context
(Filename: Assets/Hangman.cs Line: 32)
Assets/Hangman.cs(47,47): error CS0122: `string.length' is inaccessible due to its protection level
(Filename: Assets/Hangman.cs Line: 47)
Assets/Hangman.cs(53,47): error CS0103: The name `guessedWord' does not exist in the current context
(Filename: Assets/Hangman.cs Line: 53)
Error: Analytics Event: 5(Compiler*error CS0103*The name `guessedWord' does not exist in the current context)(1): skipped because it was sent more than once in 0.10 seconds
Assets/Hangman.cs(54,69): error CS0103: The name `guessedWord' does not exist in the current context
(Filename: Assets/Hangman.cs Line: 54)
Error: Analytics Event: 5(Compiler*error CS0103*The name `guessedWord' does not exist in the current context)(1): skipped because it was sent more than once in 0.10 seconds
Assets/Hangman.cs(54,33): error CS0103: The name `guessedWord' does not exist in the current context
(Filename: Assets/Hangman.cs Line: 54)

So now I know the lines numbers you did not mention. So, I can now tell:

  • Line 32 - you can used checkChar() when your function is called CheckChar().
  • Line 47 - you have an assignment to x where you probably mean a < character.
  • Line 53 - guessedWord should have a lowercase w.
  • Line 54 - same as line 53

So, you now know how to troubleshoot these errors for yourself, and I’ve given you solutions to your problems.

Thanks for your time replying back , much appreciated! is there any way i could contact you like skype etc? im a bit stuck and need some help. looks like you know your stuff. if you could add harry.grewall on skype i would really appreciate it thanks!

A) You should hit the drop down and make this in to a comment - it's not an answer. B) No - having offline conversations defeats the purpose of Unity Answers - specifically that by answering questions, a knowledgebase is created where others can find answers to similar problems. Add more info in a comment and let further conversation happen here.

hi im getting this error. at line 48 it says ; "string" does not contain a definition for "length" and no extension method for "length" accepting a first argument of type "string" could be found ( are you using a directive or an assembly reference?) error code : CS1061 Please help?

someone please?

The message is fairly clear. You tried to use "length" and the string doesn't have "length". In C# most properties in the standard libraries are uppercased on the first letter - .Length is the length property. No one answered because the error message isn't hard to read and understand. If you can't troubleshoot basic compiler output messages, you're not setting yourself up for much success down the road.