I'm new to Unity and have been struggling with a Syntax error for the past 5 hours

Hey, sorry for the long intro but I’m pretty new to Unity and I’ve been dealing with this error coming up

Assets\Impossible Odds\Toolkit\Runtime\Core\ReflectionCaching\ReclectionCachingException.cs(7,49): error CS1003: Syntax error, ‘,’ expected

I’ve been trying to fix it and I’ve been looking through every thread but nothing is working

This is the full code:

using UnityEngine;
using System.Collections;

namespace ImpossibleOdds.ReflectionCachingExeption

{
public class ReflectionCaching : ImpossibleOdds;
{
public ReflectionCaching()
{ }

public ReflectionCaching(string errMsg) : base(errMsg)
{ }

public ReflectionCaching(string errMsg, params object[ ] format) : base(errMsg, format)
{ }
}
}

Welcome.

I guess you mean you’re new to C#? So you know, C# isn’t exclusive to Unity and there are thousands of places at your fingertips that detail the language syntax.

The compiler error (not a “Bug” as tagged) is saying that on Line 7, Column 48 it expected a comma so you made a mistake there or somewhere before it.

You’ve put a “;” at the end of the class definition i.e. “public class ReflectionCaching : ImpossibleOdds;” which is wrong.

If you search online on how to define a class in C#, you’d not need to spend 5 hours at it. :slight_smile:

I searched “C# class” and the following site is one of many that came up:

The forums do assume a basic working knowledge of C# TBH.

Hello, thank you for the links but even though I checked them, it didn’t work, I’m still trying and looking around but nothing is working.

You checked the link “and it didn’t work”? I told you what the problem was above.

Please read what I wrote again.

Yes I read it many times, I checked every place where the comma could be, and before it. Also reading through the links and checking if they would help in the code (i did change the names in them so it wouldn’t be the example given) but it still isn’t working.

I’ll repeat, you’ve put a “;” at the end of the class definition i.e. “public class ReflectionCaching : ImpossibleOdds;” which is wrong.

If you don’t understand the above then I don’t know what to say so here it is explicitly typed for you:

Incorrect.

public class ReflectionCaching : ImpossibleOdds;

Correct.

public class ReflectionCaching : ImpossibleOdds

^ ^ ^ ^ ^ I have no idea what the above is but it cannot possibly be beginner material.

Reflection and Caching and Exceptions are all EXTREMELY advanced topics.

You should be doing stuff like Flappy Birds for your first 10 or 20 game projects, not something involving reflection and caching!!!

Imphenzia: How Did I Learn To Make Games:

Tutorials and example code are great, but keep this in mind to maximize your success and minimize your frustration:

How to do tutorials properly, two (2) simple steps to success:

Step 1. Follow the tutorial and do every single step of the tutorial 100% precisely the way it is shown. Even the slightest deviation (even a single character!) generally ends in disaster. That’s how software engineering works. Every step must be taken, every single letter must be spelled, capitalized, punctuated and spaced (or not spaced) properly, literally NOTHING can be omitted or skipped.
Fortunately this is the easiest part to get right: Be a robot. Don’t make any mistakes.
BE PERFECT IN EVERYTHING YOU DO HERE!!

If you get any errors, learn how to read the error code and fix your error. Google is your friend here. Do NOT continue until you fix your error. Your error will probably be somewhere near the parenthesis numbers (line and character position) in the file. It is almost CERTAINLY your typo causing the error, so look again and fix it.

Step 2. Go back and work through every part of the tutorial again, and this time explain it to your doggie. See how I am doing that in my avatar picture? If you have no dog, explain it to your house plant. If you are unable to explain any part of it, STOP. DO NOT PROCEED. Now go learn how that part works. Read the documentation on the functions involved. Go back to the tutorial and try to figure out WHY they did that. This is the part that takes a LOT of time when you are new. It might take days or weeks to work through a single 5-minute tutorial. Stick with it. You will learn.

Step 2 is the part everybody seems to miss. Without Step 2 you are simply a code-typing monkey and outside of the specific tutorial you did, you will be completely lost. If you want to learn, you MUST do Step 2.

Of course, all this presupposes no errors in the tutorial. For certain tutorial makers (like Unity, Brackeys, Imphenzia, Sebastian Lague) this is usually the case. For some other less-well-known content creators, this is less true. Read the comments on the video: did anyone have issues like you did? If there’s an error, you will NEVER be the first guy to find it.

Beyond that, Step 3, 4, 5 and 6 become easy because you already understand!

Finally, when you have errors, don’t post here… just go fix your errors! Here’s how:

You might need to send a screenshot of the code at this point. I’m very curious what the issue could be.

Sometimes compile errors are directly useful and tell you exactly what you need to do. Sometimes, especially with syntax errors, the compiler is so far from making sense of what you’re trying to do that it can’t suggest the actual correction. This is an example of the latter.

You are not missing a comma. There are ways in which inserting a comma (and some other things) could fix it, but us other coders (as humans with brains) can tell that that is not your intention. The compiler doesn’t have a brain, it can’t work that out, so it gives you the first thing in its list of things it might expect to be there.

The actual problem is a semicolon that shouldn’t be there. It seems like you skimmed the replies for links to read but didn’t read the actual comments themselves, because this was in the first reply and you never mention trying it:

:hushed: SWEET MOTHERBOARD OF SILICON!!!

I think you are confused on how classes work and for some reason think:

namespace ImpossibleOdds.ReflectionCachingExeption { }

Is somehow a class… which it’s not by the way…

A class looks like this:

public class ReflectionCaching : ImpossibleOdds { }

IF in fact your class of ReflectionCaching.cs is supposed to Inherit from the ImpossibleOdds.cs ?

So why you type it as:

namespace ImpossibleOdds.ReflectionCachingExeption
{
   public class ReflectionCaching : ImpossibleOdds ; { }
}

Is beyond me, the compiler, and anyone else who looked into this post… Actually a squirrel looked into my window just now and he dropped his nut…

Yes I know. I DID that one as well. I STILL get the message

Thing is I didn’t write this at all. I opened a new project and imported assets I had. And When this error popped up I tried locating the script to delete it since it wasn’t mine but it doesn’t even show up. Therefore I’m forced to find the error and try to fix it

I did remove that because It didn’t work. I tried to see what effect it would have because of a Workshop I had taken for unity. I remember sth my professor told me there and just tried it out but it didn’t work. I have removed it and have very carefully read the messages. I just can’t solve it.

This is the ONLY error I haven’t resolved yet

You’ve declared ImpossibleOdds as a namespace but you’re trying to inherit from it. You can’t do both.

By my reading, so far absolutely NOTHING in this thread has been related to C# under Unity3D.

There’s nothing in here that relates in anyway to the UnityEngine and UnityEditor namespaces.

Are you even sure you are even posting in the right forum here??

I mean you’re always welcome to be here of course, but it’s a little bit like you brought your car into the supermarket to see if they could fix it.

How about: what are you TRYING to do. Use this template and everybody here will save a LOT of wasted spinning time, now that we’re up to 17 responses.

How to report your problem productively in the Unity3D forums:

http://plbm.com/?p=220

This is the bare minimum of information to report:

  • what you want
  • what you tried
  • what you expected to happen
  • what actually happened, log output, variable values, and especially any errors you see
  • links to documentation you used to cross-check your work (CRITICAL!!!)

The purpose of YOU providing links is to make our job easier, while simultaneously showing us that you actually put effort into the process. If you haven’t put effort into finding the documentation, why should we bother putting effort into replying?

If you post a code snippet, ALWAYS USE CODE TAGS:

How to use code tags: Using code tags properly

  • Do not TALK about code without posting it.
  • Do NOT post unformatted code.
  • Do NOT retype code. Use copy/paste properly using code tags.
  • Do NOT post screenshots of code.
  • Do NOT post photographs of code.
  • ONLY post the relevant code, and then refer to it in your discussion.

As you can see, you don’t get the same messge, you get another one as described above.

  • Please use code tags so we have syntax highlighting and line numbers
  • Please use a … viable… IDE so YOU have syntax highlighting and line numbers
  • As others said: You fixed the original error. Now you get a different one.
  • As others said: ImpossibleOdds is not a type. You can not inherit from it.
  • You are clearly a beginner. Whatever you do is not a beginner topic. WHY are you doing this?

TL;DR: Stop torturing yourself. Set up an environment in which you can work properly, pay attention to what people actually tell you, and work on a topic appropriate to your skill level to build experience. What you are doing now is not helping you in any way, shape or form.

Closing.
You need to go through some beginning tutorials for C#. This forum is not for that. You cannot build a game without learning the basics, and expect to others to hold your hand through very basic typos and structure.
There are links above that have been posted to start your journey.