Error CS8025: Parsing error

I was just learning some codes and there was a error called error CS8025: Parsing error


I can’t find what’s wrong with my code so please help me

relevant information
my unity version is 4.7.2

Let’s see if I can provide some insight. Other people are better equipped to give you the full answer, so I assume someone will add to my comments later. But perhaps I can give you some pointers to get on the right path:

I used Google to check for possible solutions, this my first recommendation.

  1. The third if statement, also the second else if statement in your code is missing brackets. it’s
    else if (condition){ consequence}
    image
    Fix the brackets.

  2. Capitalize. C# is very case sensitive and treats HandleSpelling() entirely different from handlespelling, or Handlespelling. I still have to completely grasp what should and shouldn’t bet capitalized, but when in doubt: DO IT. Especially for classes, method etc.
    (variables like max, min and guess can be lower caps)
    So start with
    public class NumberWizard not numberwizard
    void NextGuess() not nextguess (both in method and in referring to method)
    Check everything on capitals, a very large percentage of issues are related to this. You might want to update this (ClassNames) in Unity as well.

  3. Last tip: to add everywhere

Debug.Log(“This is my current step”);

If you add that to all methods and functions, you can track in the console where you went wrong. It’s sometimes overkill and sometimes a lifesaver. In your situation if you add (after the game is running again), something ike

Debug.Log ("NextGuess has started with the variables guess " + guess + " min " + min + " max " + max);

can you show me the fixed code to?

Nope! But you’ll get there if you investigate.

okay… but thanks for your help!! :smiley:

I did it !! I solved it because of your help Duckfest_JF !!!
I really appreciate .

Just as a heads up, it’s easier for people to help when you copy/paste your code into the forum, it enables them to subsequently copy/paste parts of it rather than having to re-type it from screenshots.

Screenshots can, of course, be very useful for error messages or details from the Unity editor.

Glad you have resolved your problem @2004 and well done for helping @Duckfest_JF :slight_smile:


See also;

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms