C
C#15mo ago
Werlon

✅ (Solved) Why am i getting this error?

33 Replies
sibber
sibber15mo ago
$code
MODiX
MODiX15mo ago
To post C# code type the following: ```cs // code here ``` Get an example by typing $codegif in chat If your code is too long, post it to: https://paste.mod.gg/
sibber
sibber15mo ago
at the very least put a little bit of effort into taking the picture lol and show the whole file
TheRanger
TheRanger15mo ago
can u show the whole code oh, local variables can't have access modifiers
Werlon
Werlon15mo ago
Alright one sec And what does that mean?
TheRanger
TheRanger15mo ago
local variable is a variable that is defined in a method not in the class
Werlon
Werlon15mo ago
Why can't it have access modifiers?
TheRanger
TheRanger15mo ago
because the variable only exists in the method and gets discarded when the method ends its execution
Werlon
Werlon15mo ago
Ah
TheRanger
TheRanger15mo ago
you probably want a field instead
Werlon
Werlon15mo ago
And the variables in the class stay?
TheRanger
TheRanger15mo ago
yes
Werlon
Werlon15mo ago
What's that?
TheRanger
TheRanger15mo ago
when u define a variable in the class level, its called a field
Werlon
Werlon15mo ago
Alright thank you
TheRanger
TheRanger15mo ago
i advice u to learn the basics of C# before doing Unity
Werlon
Werlon15mo ago
I did but i kinda forgor Was a year ago
sibber
sibber15mo ago
relearn :)
TheRanger
TheRanger15mo ago
^
Werlon
Werlon15mo ago
Yup that's the plan
sibber
sibber15mo ago
not alongside unity $close
MODiX
MODiX15mo ago
Use the /close command to mark a forum thread as answered
Werlon
Werlon15mo ago
Why not? I want to learn both And i get to learn c# along the way better in practice
sibber
sibber15mo ago
learning at the same time will be significantly harder
Werlon
Werlon15mo ago
Ah
sibber
sibber15mo ago
its like learning physics and math at the same time you need to know math in order to learn physics
Werlon
Werlon15mo ago
But i was having problems using c# It felt pointless because I didn't know what to do even if i knew how to code
sibber
sibber15mo ago
theres $projects
MODiX
MODiX15mo ago
Collections of application ideas that anyone can solve in any programming language to improve coding skills: https://github.com/dotnet/dotnet-console-games https://github.com/karan/Projects https://github.com/florinpop17/app-ideas
Werlon
Werlon15mo ago
So I'm using a game engine to kinda make a point to work towards
sibber
sibber15mo ago
learn the basics, create a couple simple ones, then go learn unity
Werlon
Werlon15mo ago
Thank you
sibber
sibber15mo ago
np