✅ I dont know what im doing wrong?!
go easy as im very new, im essentially making a simple match 3 game to learn c#.
ive managed to get my game board to generate, but i cant seem to figure out why im getting a CS1001 and CS1002 errors in this pictured area.
origonally i was getting a CS0844 error but have since fixed that with a "this." but now i get the previous mentioned errors. im trying to figure it out on the microsoft learn but im still not overly sure what to change to make it work ?!
some help would be greately appreciated!
34 Replies
What are those errors?
CS1001 "identifier expected"
CS1002 just says "expected" ?
Well, I can see at least one issue here
Curious why the IDE doesn't highlight it in red
Is it VS Code?
yes
$vscode
Follow the instructions here on getting started with DevKit for C# in VSCode: https://code.visualstudio.com/docs/csharp/get-started
Get started with C# and .NET in Visual Studio Code
Getting Started with C# and .NET Development in Visual Studio Code
Make sure you have
DevKit
installedIn any case, this
Are you creating a new variable? If so, the
this
should not be there
Are you trying to change the value of an existing property/field? If so, then the int
sholdn't be therewhen i take the "this." out it tells me i cant use local variable before it is declared.
Again, what are you trying to do here?
Change the value of existing variable? Then don't declare the type.
Create a whole new variable? Then give it a new name, don't reference an existing field/property
im trying to get the token to randomly generate between the numbers of 0 and 7
I don't know what token is
Is this Unity?
sorry my apologies, basically at the start of this script, ive made "token" as part of an array, so the line of code you highlighted is for it to pick a number between 0 and 7 (as thats how many "tokens" there will be) and then generate them randomly within the board.
Sooooo...
TokenToUse
is an existing property or field of the class, yes?yes
Remove the
int
thenit now gives me these lovely things
maybe i start over?
Are you sure the property is actually there?
Not in some other file?
Some other class?
i think i may have missed it, its not in another script, its only mentioned here.
If that was the case, the first error would not be there
could it be because i wrote the other script in visual studio 22?
or would that not matter?
It wouldn't matter
Can you send the whole file here?
Well, the $code of the whole file?
To post C# code type the following:
```cs
// code here
```
Get an example by typing
$codegif
in chat
For longer snippets, use: https://paste.mod.gg/want me to just paste the code or screenshot it?
It's easier to read if you paste it in a code block the way that the bot described. And if it's a larger file, use the link and host it there
I'll take another look later after work, thank you for the patience and input.
omfg, ive figured it out
it was a simple name confliction within the ( ) and the rest of the code, it now works, thank you for the help!
for reference it was the names highlighted that needed to be different. i shouldnt be figuring out code at 1am lol thanks again though @ZZZZZZZZZZZZZZZZZZZZZZZZZ
Glad you got it sorted!
should i leave this post up incase others come across similar issues or shall i close it?
If you $close it it will stay up
Use the /close command to mark a forum thread as answered
Just gonna get a green checkmark next to the title