C
C#13mo ago
_ht4m

❔ ✅ How am I making errors?

so I'm pretty sure that i'm correct but here are the pics:
392 Replies
_ht4m
_ht4m13mo ago
_ht4m
_ht4m13mo ago
phaseshift
phaseshift13mo ago
Is this top level script? The class needs to go at the bottom
_ht4m
_ht4m13mo ago
class wizard ? im a beginner..
phaseshift
phaseshift13mo ago
You don't write your own main any more Put the class at the bottom of the file
_ht4m
_ht4m13mo ago
can u show me an example pls? SORRY I KNOW I SUCK LMAO I just started 5 days ago lol
phaseshift
phaseshift13mo ago
I'm on mobile, can't really type out so much Put your class at the bottom of the page. Delete the line with static void main
ZacharyPatten
ZacharyPatten13mo ago
in general C# code needs to be inside classes and methods. as was mentioned you are mixing a class with top level statements. if you do that, the class has to be defined at the bottom of the file because that is just how top level statements were designed to work. so you need to move
class wizard {
...
}
class wizard {
...
}
below all your other code and if you are going to have static void Main(...) {... then it needs to be inside a class
_ht4m
_ht4m13mo ago
What about those?
ZacharyPatten
ZacharyPatten13mo ago
those are called "fields" they are defined inside of classes as you have done
_ht4m
_ht4m13mo ago
oh alright.. Now i get it, Thanks! by the way why for people it types using system; namespace and static void main.. but for me it doesnt????
ZacharyPatten
ZacharyPatten13mo ago
using ...; at the top of a file is called a "using directive" when you want to use a member that is inside another namespace, you either need to fully qualify the member or you need to add a using directive at the top of the file that will effect all code in that file there is a feature called "implicit usings" that was added in a recent version of C# that will automatically pull in some of the most common using directives you can disable "implicit usings" in your .csproj file if you don't like it
daniel2
daniel213mo ago
@zacharypatten can I ask a question?
ZacharyPatten
ZacharyPatten13mo ago
you only got one question and that was it good job... jk ask your question
daniel2
daniel213mo ago
What does this mean Name {get; set;}
ZacharyPatten
ZacharyPatten13mo ago
that is a "property"
daniel2
daniel213mo ago
Private and public
ZacharyPatten
ZacharyPatten13mo ago
"private" and "public" are "access modifiers"
daniel2
daniel213mo ago
What’s the difference
ZacharyPatten
ZacharyPatten13mo ago
Access Modifiers - C# Programming Guide
All types and type members in C# have an accessibility level which controls whether they can be used from other code. Review this list of access modifiers.
ZacharyPatten
ZacharyPatten13mo ago
the documentation is your friend. "private" means you can only access it from inside the current class "public" means you can access it from anywhere
_ht4m
_ht4m13mo ago
ZP @zacharypatten
_ht4m
_ht4m13mo ago
how to fix this?
ZacharyPatten
ZacharyPatten13mo ago
you make sure all top level statements come before any type definitions the error is pretty self explanatory
_ht4m
_ht4m13mo ago
never mind yeah im so dumb lma0o lmao well what do u expect im still a beginner started since 5 days
ZacharyPatten
ZacharyPatten13mo ago
just don't ignore the errors. C# has excellent errors that will often tell you what the problem is compare C# errors to C errors and C errors will make you cry cause they aren't helpful for shit
_ht4m
_ht4m13mo ago
C++ errors are pain brackeys courses are so freaking helpful but they're not that simple yet very simple idk if that makes sense but .
ZacharyPatten
ZacharyPatten13mo ago
youtube videos are the worst way to learn how to code you learn how to follow directions not problem solve just my opinion 😉
_ht4m
_ht4m13mo ago
no I just learn how it works lol @zacharypatten
_ht4m
_ht4m13mo ago
_ht4m
_ht4m13mo ago
_ht4m
_ht4m13mo ago
ZacharyPatten
ZacharyPatten13mo ago
name and favouritespell are fields of wizard you have to access them from an instance of a wizard "name"->"wizard01.name"
_ht4m
_ht4m13mo ago
ohhh tysm
_ht4m
_ht4m13mo ago
_ht4m
_ht4m13mo ago
now good?
ZacharyPatten
ZacharyPatten13mo ago
well your code will compile now Are you using Visual Studio Code? If you are a beginner you should really use Visual Studio not Visual Studio Code
_ht4m
_ht4m13mo ago
whats the difference? im using code
ZacharyPatten
ZacharyPatten13mo ago
Visual Studio is a fully featured IDE and Visual Studio Code is more of a text editor in comparison
_ht4m
_ht4m13mo ago
whats an IDE ;-;
ZacharyPatten
ZacharyPatten13mo ago
google is your friend
_ht4m
_ht4m13mo ago
alr
_ht4m
_ht4m13mo ago
oh
_ht4m
_ht4m13mo ago
. instantly oh thats cool oh god not again
_ht4m
_ht4m13mo ago
_ht4m
_ht4m13mo ago
im getting a red line on console.readke readkey* ..
ZacharyPatten
ZacharyPatten13mo ago
take your time learn from your mistakes so you don't make them again
_ht4m
_ht4m13mo ago
ok thats a simple error
_ht4m
_ht4m13mo ago
ik what to do . ZP thanks for ur help if i struggled with anything can I dm u? no wonder why help channel exist
ZacharyPatten
ZacharyPatten13mo ago
I would rather keep discussions on this discord server, but you may "@" me if you wish
_ht4m
_ht4m13mo ago
.... alr
ZacharyPatten
ZacharyPatten13mo ago
you cannot put top level statements after a type or namespace declaraction class wizard { ... } is a type declaration you are declaring a "class" type that you are calling "wizard" Console.ReadKey(); needs to come before class wizard { ... } if you want it run as a top level statement with the other code --- generally in C# you should only ever declare one class per file you are declaring two classes in this file and that is clearly causing you issues so if it were me... I would make a new file wizard.cs and define class wizard in that file also I would start using Visual Studio instead of VSC
_ht4m
_ht4m13mo ago
well I googled VS but I only see VSC
ZacharyPatten
ZacharyPatten13mo ago
Visual Studio
Download Visual Studio Tools - Install Free for Windows, Mac, Linux
Download Visual Studio IDE or VS Code for free. Try out Visual Studio Professional or Enterprise editions on Windows, Mac.
_ht4m
_ht4m13mo ago
But those are saved in
_ht4m
_ht4m13mo ago
@zacharypatten
ZacharyPatten
ZacharyPatten13mo ago
I don't know what you are asking, but you need to learn how classes work
_ht4m
_ht4m13mo ago
fax
ZacharyPatten
ZacharyPatten13mo ago
you can use classes that are defined in other files
_ht4m
_ht4m13mo ago
and I also dont know whats return I know but i like idk when to use it
JakenVeina
JakenVeina13mo ago
you use it when you want to awesome
_ht4m
_ht4m13mo ago
. makes no sense lamo lmao
JakenVeina
JakenVeina13mo ago
wrap your head around how methods work and what the call stack is and it'll make perfect sense "return" means that you're "returning" to the caller of the method
_ht4m
_ht4m13mo ago
good reminder I forgot methods again my memory sucks
ZacharyPatten
ZacharyPatten13mo ago
what are you trying to make? you seem to be stumbling around trying to learn C#, but you will struggle to learn just from dabbling alone. try to have a goal in mind like "I want to make rock-paper-scissors" then you know what you want and you can try to achieve that by tinkering and learning C#
_ht4m
_ht4m13mo ago
its like a fish memory lmao
JakenVeina
JakenVeina13mo ago
good advice a little bit of goal can go a long way
_ht4m
_ht4m13mo ago
1 thing I cant memorize anything my memory suck
ZacharyPatten
ZacharyPatten13mo ago
you don't need a good memory to code you need good problem solving skills
_ht4m
_ht4m13mo ago
I forgot methods 2 times wdym
JakenVeina
JakenVeina13mo ago
I mean... you kinda do... but it's not really a memory thing, it's a practice thing
ZacharyPatten
ZacharyPatten13mo ago
no one remembers every single syntax nuance in C# or every method in the base class library we are constantly googling, reading documentation, reading compiler errors, etc. so you will never know everything you need to know it just won't happen you need to learn how to problem solve
_ht4m
_ht4m13mo ago
m kinda good at that, only if there was my own language in VS ..
ZacharyPatten
ZacharyPatten13mo ago
C# is an extremely easy language to learn compared to nearly every other language imo
_ht4m
_ht4m13mo ago
well it depends for exmaple, if ur not interested in F#, but u still want to learn it.. it will become hard and boring cuz ur not even interested in it..
ZacharyPatten
ZacharyPatten13mo ago
well if you are not interested in learning C#... why are you?
_ht4m
_ht4m13mo ago
im im interested in learning it but im just giving an example C# is fun.
ZacharyPatten
ZacharyPatten13mo ago
Do you have a plan for how you want your game to work? im going back to the "try to have a goal" comment. focus on your game and what you want it to do
_ht4m
_ht4m13mo ago
Kinda yes, But im not confident that my game will actually be famous and yk I just want to be a dev.. and i dont rly know it works, but I want to be a dev in a big company. thats just my goal.
ZacharyPatten
ZacharyPatten13mo ago
take it slow. you have a long way to go. not that you can't achieve that, but you still have a lot to learn. I'm talking about your current game you are making in the console here you are making a wizard and printing some output, but what else do you want your game to do?
_ht4m
_ht4m13mo ago
Oh, if that's the case.. Then I just want to make a wizard that casts spells on other objects.. its pretty simple and it destroys objects
ZacharyPatten
ZacharyPatten13mo ago
well you have a wizard, but you don't have anything else currently. how about you start adding stuff? and are you trying to make like a turn based RPG? or just a basic visual novel without any decisions for the player to make? right now, you jsut output text tot he player. the player doesn't get to make any decisions
_ht4m
_ht4m13mo ago
No, I meant like the player could move the wizard and casts spells..
ZacharyPatten
ZacharyPatten13mo ago
okay, you want movement
_ht4m
_ht4m13mo ago
Yeah.
ZacharyPatten
ZacharyPatten13mo ago
I can link some examples that have movement. would you liek some examples?
_ht4m
_ht4m13mo ago
sure
_ht4m
_ht4m13mo ago
uhh.. that looks pretty complicated
_ht4m
_ht4m13mo ago
lol
ZacharyPatten
ZacharyPatten13mo ago
also, there is a github repository with console game examples: https://github.com/dotnet/dotnet-console-games There are several games with WASD movement: - Snake - Role Playing Game - Console Monsters - Gravity There are games with movement that is handled via commands like "up", "down", "left", and "right": - Wunpus World There are games with limited movement like you can only flap your wings or steer left and right: - Flappy Bird - Drive and other games have other forms of movements as well like your current cursor locations did you try the code for yourself?
_ht4m
_ht4m13mo ago
like copypaste?
ZacharyPatten
ZacharyPatten13mo ago
yeah
_ht4m
_ht4m13mo ago
no
ZacharyPatten
ZacharyPatten13mo ago
how about you try it
_ht4m
_ht4m13mo ago
wait how do I use VS i only know VSC
ZacharyPatten
ZacharyPatten13mo ago
did you download VS yet?
_ht4m
_ht4m13mo ago
YES yes * I installed it with C# now what do i do?
ZacharyPatten
ZacharyPatten13mo ago
make a new C# console project
_ht4m
_ht4m13mo ago
looks sick
ZacharyPatten
ZacharyPatten13mo ago
it should open to the launcher
_ht4m
_ht4m13mo ago
on or off?
ZacharyPatten
ZacharyPatten13mo ago
up to you
_ht4m
_ht4m13mo ago
what does it even mean LMAO i suck at english jk im good at english i didn't understand statements thats all. oh
_ht4m
_ht4m13mo ago
_ht4m
_ht4m13mo ago
ZP i have a baby bird to feed every 2-3 hours so at anytime u might see me just not responding im just handfeeding em .
ZacharyPatten
ZacharyPatten13mo ago
have fun... everyone on this server is generally multitasking 😛 I'm playing Indiana Jones and the Emporer's Tomb atm... it kinda sucks... but trying to get hype for new movie
_ht4m
_ht4m13mo ago
it didnt generate top level statements.. bruh . well uh honestly VSC gui is much better than this tbh
ZacharyPatten
ZacharyPatten13mo ago
bruh you jsut opened it for the first time... you shouldn't judge stuff when you have no experience 😛 give it a bit of time
_ht4m
_ht4m13mo ago
lol anw so um thats all now I start?
ZacharyPatten
ZacharyPatten13mo ago
so how about you try running your code? you can do so with the green triangle at the top
ZacharyPatten
ZacharyPatten13mo ago
ZacharyPatten
ZacharyPatten13mo ago
yours probably says "ConsoleApp1" unless you put in a custom name, which is fine if you did
_ht4m
_ht4m13mo ago
oh its working
_ht4m
_ht4m13mo ago
_ht4m
_ht4m13mo ago
cool
ZacharyPatten
ZacharyPatten13mo ago
nice
_ht4m
_ht4m13mo ago
but now how do I make my OWN wasd game? or movement whatever
ZacharyPatten
ZacharyPatten13mo ago
well look at what the code is doing. it is using Console.ReadKey(true) to read the keys that the user is pressing if the user pressed "W" or the "UpArrow" it will move the player's position up by subtracting from the player's Y coordivate cause in this case the top left is coordinate 0, 0
_ht4m
_ht4m13mo ago
thats quite hard to understand for beginners..
ZacharyPatten
ZacharyPatten13mo ago
breakpoints are your friend
_ht4m
_ht4m13mo ago
aaaaaaaaaaaand what is a breakpoint ..
Feast
Feast13mo ago
Debugger.Break()
JakenVeina
JakenVeina13mo ago
it's a point where you break
_ht4m
_ht4m13mo ago
.
JakenVeina
JakenVeina13mo ago
I.E. pause you pause the program at specific points in code so you can inspect what's going on like look at the values of certain variables in the middle of the program running
ZacharyPatten
ZacharyPatten13mo ago
see the red dot to the left of the code? that is a breakpoint. while your code is running, if it reaches that line of code with the red dot it will stop and you want look at what the code is doing
ZacharyPatten
ZacharyPatten13mo ago
and you can step through the code while it is running line-by-line with the F11 key
_ht4m
_ht4m13mo ago
maybe programming isnt for me.. i never understand anything in it lmao
JakenVeina
JakenVeina13mo ago
that's normal
ZacharyPatten
ZacharyPatten13mo ago
you can't expect to become a programmer over the course of an hour or two. it takes time
JakenVeina
JakenVeina13mo ago
becoming a programmer usually means re-learning how to think there's a significant barrier to entry but all it takes to get past it is practice
_ht4m
_ht4m13mo ago
ZP how tf do u expect me to understand all of this?
ZacharyPatten
ZacharyPatten13mo ago
ask questions read each line of code. what is the first line of code you don't understand?
_ht4m
_ht4m13mo ago
1 sec gotta do smthing ima leave WASD later
ZacharyPatten
ZacharyPatten13mo ago
not a bad idea, there are easier games to get started on than trying to make one with WASD movement like rock-paper-scissors
JakenVeina
JakenVeina13mo ago
or solitaire or battleship
_ht4m
_ht4m13mo ago
bro vs sucks compared to vsc tbh but .
JakenVeina
JakenVeina13mo ago
looooooooooooooool, no not for C# and not for beginners
_ht4m
_ht4m13mo ago
which one u mean vs or vsc ngl I prefer vsc but ok easier to use tbh
JakenVeina
JakenVeina13mo ago
no offense, but that's cause you don't know any better you don't know about all the tooling that you're missing in VS Code which you CAN add in the form of VS Code plugins and such and approximate the experience of Visual Studio VS is tailor-made for C# development (also C++ and other .NET languages, but yeah) it's a first class experience the experience you get with VS Code depends on how knowledgeable you already are with how C#/.NET works, and how all the tooling works, and whether or not you know how to properly configure it
_ht4m
_ht4m13mo ago
VSC = visual studio code @ReactiveVeina
JakenVeina
JakenVeina13mo ago
....yes, as does "VS Code"
_ht4m
_ht4m13mo ago
not the tools
JakenVeina
JakenVeina13mo ago
that's my point
_ht4m
_ht4m13mo ago
brih I meant something else
JakenVeina
JakenVeina13mo ago
VS Code doesn't inherently include tooling
_ht4m
_ht4m13mo ago
other than tools like the gui and how it looks is what I meant.
JakenVeina
JakenVeina13mo ago
it's not significantly different than VS
_ht4m
_ht4m13mo ago
it is
JakenVeina
JakenVeina13mo ago
just enough to make it feel different, if you're not used to it but not very meaningful when it comes to functionality
_ht4m
_ht4m13mo ago
vsc looks better than vs
JakenVeina
JakenVeina13mo ago
right, not meaningfully different enough that it's a matter of personal preference, and doesn't affect what you can DO with it and enough that you could get used to either one
_ht4m
_ht4m13mo ago
Idk i just dont rly like vs but I need to use it so .
JakenVeina
JakenVeina13mo ago
which is fine but use it for any amount of time, and you'll likely appreciate what it has FUNCTIONALLY that VS Code doesn't outside of just text editing
_ht4m
_ht4m13mo ago
why do I feel like VS is different from vsc cuz in vsc its correct but here its wrong:
JakenVeina
JakenVeina13mo ago
uhh it's not correct
_ht4m
_ht4m13mo ago
_ht4m
_ht4m13mo ago
..
JakenVeina
JakenVeina13mo ago
yes
_ht4m
_ht4m13mo ago
y is it correct in VSC?
JakenVeina
JakenVeina13mo ago
it's not
ZacharyPatten
ZacharyPatten13mo ago
it wasnt
JakenVeina
JakenVeina13mo ago
VS Code just isn't reporting the errors to you, until you compile
_ht4m
_ht4m13mo ago
ZP ur finally back
JakenVeina
JakenVeina13mo ago
VS Code doesn't give you live feedback
_ht4m
_ht4m13mo ago
which I can agree with . lol But I ran the program a LOT of times yet only yellow lines, no red line ..
JakenVeina
JakenVeina13mo ago
define "ran the program"
_ht4m
_ht4m13mo ago
maybe nobody saw that i realized the error LOL I didn't sleep for like 8 hours lol
JakenVeina
JakenVeina13mo ago
awesome
_ht4m
_ht4m13mo ago
yall thanks
JakenVeina
JakenVeina13mo ago
it happens
_ht4m
_ht4m13mo ago
WAIT I also have another problem that I struggled with a lot
JakenVeina
JakenVeina13mo ago
42
_ht4m
_ht4m13mo ago
i still dont know how to fix it.. 42 ?
JakenVeina
JakenVeina13mo ago
42 that's the answer to your problem
ZacharyPatten
ZacharyPatten13mo ago
42 is a hitchikers guide to the galaxy joke. google it
_ht4m
_ht4m13mo ago
now better
ZacharyPatten
ZacharyPatten13mo ago
or better yet... read the booke 😛
JakenVeina
JakenVeina13mo ago
or watch the movie both are good
ZacharyPatten
ZacharyPatten13mo ago
i love da movie 🙂
_ht4m
_ht4m13mo ago
never heard of it i dont rly watch movies anyways what happens if i switch int and float with VAR? or var sorry caps
JakenVeina
JakenVeina13mo ago
depends where you mean
_ht4m
_ht4m13mo ago
i think its the same
_ht4m
_ht4m13mo ago
JakenVeina
JakenVeina13mo ago
if you do it within a property or field definition, you'll get a compiler error for two reasons A) that's simply not allowed B) even if it were allowed, the compiler can't tell what you WANT the type to be the point of var is that it's shorthand for int or float or any other type IF the compiler can figure out what the type is supposed to be, from context var is only valid when declaring local variables like, inside a method body
_ht4m
_ht4m13mo ago
oh
JakenVeina
JakenVeina13mo ago
var myVariable = 0;
var myVariable = 0;
_ht4m
_ht4m13mo ago
. nvm then i would get a compiler error if i switch float and int with var
_ht4m
_ht4m13mo ago
JakenVeina
JakenVeina13mo ago
here, the compiler figures that var should be int, since that's the type of 0
var myVariable;
var myVariable;
wouldn't work, because there's no context to say what type it's SUPPOSED to be correct
_ht4m
_ht4m13mo ago
the compiler would say "wat? nvm i'll give him an error his dumb he deserves it" jkjk . lol it was just a joke
JakenVeina
JakenVeina13mo ago
an accurate one, tho 😛
_ht4m
_ht4m13mo ago
and my english sucks so sometimes I might just go to google translate lmao ima do something im not sure if its gonna work but im gonna try nothing bad is gonna happen
JakenVeina
JakenVeina13mo ago
godspeed
_ht4m
_ht4m13mo ago
reactive what does public mean? i forgot . public int etc
JakenVeina
JakenVeina13mo ago
access modifier means anyone can access it
_ht4m
_ht4m13mo ago
oh . and private is da opposite?
JakenVeina
JakenVeina13mo ago
basically
_ht4m
_ht4m13mo ago
ik i get what u mean
JakenVeina
JakenVeina13mo ago
means only the immediate class it's defined in can access it
_ht4m
_ht4m13mo ago
i get it from the start but now ima try smthing rq 1 sec veina ur on all day tf? I feed my baby he is not a parrot thats an edit
JakenVeina
JakenVeina13mo ago
?
_ht4m
_ht4m13mo ago
. u got a pet btw?
JakenVeina
JakenVeina13mo ago
yes
_ht4m
_ht4m13mo ago
wat pet
JakenVeina
JakenVeina13mo ago
dog
_ht4m
_ht4m13mo ago
I have 3 birds
JakenVeina
JakenVeina13mo ago
neat
_ht4m
_ht4m13mo ago
well 4 birds cuz one is coming in the way lol wait so is it correct if I do like public int Castspells; then go under console.writeline and type castspells--; ? I want the spells go down when the user uses the spell ig castspells--;
JakenVeina
JakenVeina13mo ago
assuming you get the naming right, yes
_ht4m
_ht4m13mo ago
weird,
JakenVeina
JakenVeina13mo ago
Castspells and castspells are not the same thing
_ht4m
_ht4m13mo ago
_ht4m
_ht4m13mo ago
ik u need to get the correct caps i got a red line
JakenVeina
JakenVeina13mo ago
var x = Castspells-- is shorthand for...
var x = Castspells;
Castspells = Castspells - 1;
var x = Castspells;
Castspells = Castspells - 1;
_ht4m
_ht4m13mo ago
JakenVeina
JakenVeina13mo ago
right Castspells is defined as an instance member of the wizard class
_ht4m
_ht4m13mo ago
correct.. wait i gotchu
JakenVeina
JakenVeina13mo ago
you can only refer to it by specifying WHICH instance of the wizard class you want to reference
_ht4m
_ht4m13mo ago
no need to type
_ht4m
_ht4m13mo ago
JakenVeina
JakenVeina13mo ago
or by being inside another instance member of the class precisely
_ht4m
_ht4m13mo ago
now good? nvm prob wrong lmao no way its correct trying wont hurt tho
JakenVeina
JakenVeina13mo ago
I mean... there's no error beyond that, I dunno
_ht4m
_ht4m13mo ago
but look, it kinda makes sense
JakenVeina
JakenVeina13mo ago
I'd have to know what your intentions are for what that code is supposed todo
_ht4m
_ht4m13mo ago
since there is a var thats int and float, it worked.. and to access the wizard class wizard01.... other vars got the same error ( I mean i got the same error from other vars) yet this kinda makes sense that I have to put wizard01... when the user uses the spell, it goes down so like he has 7 spells, uses the spell and it goes down to 6
JakenVeina
JakenVeina13mo ago
right
_ht4m
_ht4m13mo ago
pro skills lol jk im rly bad
_ht4m
_ht4m13mo ago
umm
_ht4m
_ht4m13mo ago
what abt this one tho
JakenVeina
JakenVeina13mo ago
uhhh hmmm show me the whole file with Main() in it
_ht4m
_ht4m13mo ago
_ht4m
_ht4m13mo ago
_ht4m
_ht4m13mo ago
there goes the others
JakenVeina
JakenVeina13mo ago
?
_ht4m
_ht4m13mo ago
das the file
JakenVeina
JakenVeina13mo ago
try dropping that semicolon in the middle there
_ht4m
_ht4m13mo ago
that makes no sense but ok well it worked ..
JakenVeina
JakenVeina13mo ago
nah, it makes sense
_ht4m
_ht4m13mo ago
Y?
JakenVeina
JakenVeina13mo ago
it's just invalid syntax semicolons belong at the end of statements
_ht4m
_ht4m13mo ago
look ik but i was like changing yknow when u have uhh like Cw and u want to make it go up yea
JakenVeina
JakenVeina13mo ago
the thing that came right before that semicolon was the Main() method definition which is not a statement
_ht4m
_ht4m13mo ago
i was changing them but never noticed the semicolon
JakenVeina
JakenVeina13mo ago
and should not have a semicolon after it
_ht4m
_ht4m13mo ago
yeah i know that i was just changing the lines positions never noticed that semicolon lmao
JakenVeina
JakenVeina13mo ago
I'm actually not sure why that wasn't a straight-up error, upon the semicolon
_ht4m
_ht4m13mo ago
theres a fly annoying me . oh god wait
JakenVeina
JakenVeina13mo ago
maybe that's actually valid for local functions?
_ht4m
_ht4m13mo ago
im never gonna use my small brain so tell me if its correct or not so i wanna use console.readkey (i know the full code its just shortened) but it will not work, as its supposed to be on the wizard class.. correct ?
JakenVeina
JakenVeina13mo ago
uhhhhhh no but really, I don't know what you're asking
_ht4m
_ht4m13mo ago
ye wrong lmao 1 sec ima use my small brain again fff now correct ok now my brain upgraded from small to big XD anyways
JakenVeina
JakenVeina13mo ago
okay
_ht4m
_ht4m13mo ago
no need to eplain this was so obvious
_ht4m
_ht4m13mo ago
_ht4m
_ht4m13mo ago
well i still call myself big brain cuz i didn't sleep for almost 10 hours lol wait I woke up yesterday at 10PM . ok now I edited it
_ht4m
_ht4m13mo ago
me everyday:
_ht4m
_ht4m13mo ago
😂 @ReactiveVeina literally me everyday and um ignore this language its only the top 2 hardest language to learn yk which is my main language @zacharypatten bro nevermind he is off ..
Pobiega
Pobiega13mo ago
People are from different timezones and need to sleep and stuff, y'know. So, your last 20+ messages here are unrelated to code, so is your issue solved?
_ht4m
_ht4m13mo ago
I still have 1 issue then im done
Pobiega
Pobiega13mo ago
Okay, describe the issue
_ht4m
_ht4m13mo ago
alright, look so I want to make a console game (not done yet but part of it) so i want in text the wizard cast spells, Now here's an ss: So I struggled with this A LOT i mentioned ZP but he didn't respond
_ht4m
_ht4m13mo ago
now the You have + spells dont worry I know its supposed to be wizard01.spells but
Pobiega
Pobiega13mo ago
uhm
_ht4m
_ht4m13mo ago
public void castspell(); and wizard01.castspell; and wizard01.Castspell--;
Pobiega
Pobiega13mo ago
you are mixing top level statements with classic main you cant do that pick a style and stick to it
JakenVeina
JakenVeina13mo ago
apparently it actually compiles
Pobiega
Pobiega13mo ago
what okay, thats... uncomfortable, but whatever
_ht4m
_ht4m13mo ago
veina how?
Pobiega
Pobiega13mo ago
your current problem is that public void CastSpell(); doesnt have a body
JakenVeina
JakenVeina13mo ago
earlier, he had a stray semicolon that caused a "there is no suitable Main() method" error
Pobiega
Pobiega13mo ago
you can't declare empty methods
JakenVeina
JakenVeina13mo ago
he removed that and the error went await
_ht4m
_ht4m13mo ago
Then why am I getting redline?
Pobiega
Pobiega13mo ago
and all 3 places you try to "call" the method, you forgot the ()
JakenVeina
JakenVeina13mo ago
I was referring to your use of the main method
_ht4m
_ht4m13mo ago
correct, thanks for reminding also
JakenVeina
JakenVeina13mo ago
look
_ht4m
_ht4m13mo ago
(btw my memory is so bad so I cant remember that when u try to call a method u need() )
JakenVeina
JakenVeina13mo ago
it's time we take a different approach here
_ht4m
_ht4m13mo ago
anyways
JakenVeina
JakenVeina13mo ago
this is not about memory
_ht4m
_ht4m13mo ago
look
JakenVeina
JakenVeina13mo ago
you have errors
_ht4m
_ht4m13mo ago
yes I know
JakenVeina
JakenVeina13mo ago
what do the errors say
_ht4m
_ht4m13mo ago
1 sec
JakenVeina
JakenVeina13mo ago
you don't have to memorize everything, that's what error messages are for, the error messages will TELL you what's wrong
_ht4m
_ht4m13mo ago
memory what I mean is sometimes it happens on other thing, now i forgot that when u call a method u need () I dont understand errors , which is a big problem
JakenVeina
JakenVeina13mo ago
that's what you should focus on, then
Pobiega
Pobiega13mo ago
^
JakenVeina
JakenVeina13mo ago
understanding error messages
Pobiega
Pobiega13mo ago
learn how to read and understand the errors. thats a CORE skill
_ht4m
_ht4m13mo ago
_ht4m
_ht4m13mo ago
how do I practice understanding error msgs?
Pobiega
Pobiega13mo ago
lets begin with the top one what do you think it means
_ht4m
_ht4m13mo ago
hmm.. i think it means i have to get public void Castspell(); into main?
Pobiega
Pobiega13mo ago
?
_ht4m
_ht4m13mo ago
wait nmv nvm um
Pobiega
Pobiega13mo ago
how on earth do you get that from
The name 'Spells' does not exist in the current context
_ht4m
_ht4m13mo ago
um ez i fixed it lmao uh ignore that my brain died for a sec here ima ss and show u why.. or tell u
_ht4m
_ht4m13mo ago
_ht4m
_ht4m13mo ago
Pobiega
Pobiega13mo ago
okay. can you show the updated error list?
_ht4m
_ht4m13mo ago
_ht4m
_ht4m13mo ago
idk the first and 2nd i've been getting those for a while
Pobiega
Pobiega13mo ago
lets start with the third one down
_ht4m
_ht4m13mo ago
ye sorry my brain died there
Pobiega
Pobiega13mo ago
Cannot assign to CastSpells because its a method group
what does this tell you
_ht4m
_ht4m13mo ago
this one is pretty self explanatory.. but i have time to think soo
Pobiega
Pobiega13mo ago
hint: what is a "method group"?
_ht4m
_ht4m13mo ago
uhh the curly brackets for the method i guess? no wait MY BRAIN DIES .. NO SORRY I DIDN'T MEAN THAT MY BRAIN DIED
Pobiega
Pobiega13mo ago
no it means the symbol is a method
_ht4m
_ht4m13mo ago
bruh my brain dies
Pobiega
Pobiega13mo ago
ie CastSpells is a method not a variable, not a property, not a class
_ht4m
_ht4m13mo ago
yep..
Pobiega
Pobiega13mo ago
and you can't assign, ie change the value, of a method it says line 10, so we look at line 10
Pobiega
Pobiega13mo ago
_ht4m
_ht4m13mo ago
Pobiega
Pobiega13mo ago
so why wont that work whats wrong here
_ht4m
_ht4m13mo ago
im changing the value of the method here..
Pobiega
Pobiega13mo ago
you are.
_ht4m
_ht4m13mo ago
Pobiega
Pobiega13mo ago
or well, you're trying
_ht4m
_ht4m13mo ago
Hmm, but I want the spells go down when the user casts a spell
Pobiega
Pobiega13mo ago
So maybe that method should do that? the method that is responisble for casting a spell should also reasonably make sure spells can be cast, AND decrement the spells property
_ht4m
_ht4m13mo ago
oh umm.. that makes sense now But wait, what's the difference between static and public? @pobiega
Pobiega
Pobiega13mo ago
stop pinging
_ht4m
_ht4m13mo ago
ok sorry
Pobiega
Pobiega13mo ago
also thats an apples and oranges question public is an access modifier static means the member belongs to the class itself, not an instance of the class
_ht4m
_ht4m13mo ago
oh now back to the error
_ht4m
_ht4m13mo ago
ok oops i just randomly fixed 1 error wat
Pobiega
Pobiega13mo ago
well, quite a bit of them were interconnected one error often leads to more errors
_ht4m
_ht4m13mo ago
well yknow the castspell method instead of semicolon, i replaced it with curly brackets
Pobiega
Pobiega13mo ago
good
_ht4m
_ht4m13mo ago
turns out it was correct wat
Pobiega
Pobiega13mo ago
yes because now it has a body its an empty body, but its still a body you can't declare body-less methods unless they are abstract or in an interface
_ht4m
_ht4m13mo ago
oh now to the 3 errors
Pobiega
Pobiega13mo ago
why would you want to anyways? a body-less method by definition does nothing
_ht4m
_ht4m13mo ago
wait is it correct hold on im gonna do smthing ok wait maybe I have to put something in the curly brackets
Pobiega
Pobiega13mo ago
eventually, yes but not right now
_ht4m
_ht4m13mo ago
wise
_ht4m
_ht4m13mo ago
.. anyways it's quite hard for beginners ig not i guess but for sure
Pobiega
Pobiega13mo ago
¯\_(ツ)_/¯
_ht4m
_ht4m13mo ago
or my brain is just too small
Pobiega
Pobiega13mo ago
I think you are just rushing ahead.
_ht4m
_ht4m13mo ago
not really its been 5 days since i started
Pobiega
Pobiega13mo ago
I only briefly scrolled through the history on this thread, but I saw the word "brackeys"
_ht4m
_ht4m13mo ago
correct.
Pobiega
Pobiega13mo ago
so I guess you're following his bad and outdated tutorials?
_ht4m
_ht4m13mo ago
then wat do i do that is 100% correct.
Pobiega
Pobiega13mo ago
$helloworld
Pobiega
Pobiega13mo ago
these are good.
_ht4m
_ht4m13mo ago
do u know him? or like did u watch his toturials its time for me to sleep nrn but im bored and I might sleep so thanks and goodbye @zacharypatten
JakenVeina
JakenVeina13mo ago
stop pinging people if you have a question, ask it
_ht4m
_ht4m13mo ago
ok fine sorry why isnt the console showing anything? using System.Security.Cryptography.X509Certificates; static void Main(string[] args) { wizard wizard01 = new wizard(); wizard01.name = "Wizardie boi"; wizard01.Favouritespell = "Chounga bounga"; wizard01.Spells = 7; wizard01.experience = 0f; Console.ReadKey(); for (int i = 7; i < 8; i--) { Console.WriteLine("Spell Slots: " + wizard01.Spells); } Console.WriteLine(wizard01.name + "spells" + wizard01.Favouritespell);
} class wizard { public string Favouritespell; public string name; public int Spells; public float experience; public void CastSpell() { } } oops the copy paste messed up 1 sec oh it didn't mess up .. using System.Security.Cryptography.X509Certificates; static void Main(string[] args) { wizard wizard01 = new wizard(); wizard01.name = "Wizardie boi"; wizard01.Favouritespell = "Chounga bounga"; wizard01.Spells = 7; wizard01.experience = 0f; Console.ReadKey(); for (int i = 7; i < 8; i--) { Console.WriteLine("Spell Slots: " + wizard01.Spells); } Console.WriteLine(wizard01.name + "spells" + wizard01.Favouritespell); } class wizard { public string Favouritespell; public string name; public int Spells; public float experience; public void CastSpell() { } }
JakenVeina
JakenVeina13mo ago
standby a moment, I need to test something okay I'd like you to look at your warnings list, please
_ht4m
_ht4m13mo ago
alright
_ht4m
_ht4m13mo ago
JakenVeina
JakenVeina13mo ago
top one
_ht4m
_ht4m13mo ago
wdym top one?
JakenVeina
JakenVeina13mo ago
I mean, look at the top warning in that list
_ht4m
_ht4m13mo ago
"The local function 'Main' is declared but never used"
JakenVeina
JakenVeina13mo ago
yes, that one
_ht4m
_ht4m13mo ago
i have nothing in mind to fix it
JakenVeina
JakenVeina13mo ago
well it's telling you what's wrong Main is never used and the code you're expecting to run is inside Main so, why would you expect it to run? you never told it to run this is why I despise the "top level statements" feature as well as a whole host of other features that .NET has released in the past year or two that encourages people to write less code, at the expense of knowing how it fucking works your code is effectively...
static void Main()
{
// do some stuff
}

class MyClass
{
// define some stuff
}
static void Main()
{
// do some stuff
}

class MyClass
{
// define some stuff
}
this compiles to
namespace MyNamespace
{
static class Program
{
static void Main()
{
static void Main()
{
// do some stuff
}
}
}

class MyClass
{
// define some stuff
}
}
namespace MyNamespace
{
static class Program
{
static void Main()
{
static void Main()
{
// do some stuff
}
}
}

class MyClass
{
// define some stuff
}
}
can you see the problem now?
_ht4m
_ht4m13mo ago
hmm wait i think
JakenVeina
JakenVeina13mo ago
when you tell a .NET program to run rather, when you tell .NET to run a program it looks for a static Main() method to use as an entry point in this case, it finds MyNamespace.Program.Main() MyNamespace.Program.Main() declares a local function named Main() never calls it and then ends
_ht4m
_ht4m13mo ago
ohhhh i get it now
JakenVeina
JakenVeina13mo ago
here is your template
_ht4m
_ht4m13mo ago
but look
JakenVeina
JakenVeina13mo ago
namespace MyNamespace
{
public static class EntryPoint
{
public static void Main()
{

}
}
}
namespace MyNamespace
{
public static class EntryPoint
{
public static void Main()
{

}
}
}
use this
_ht4m
_ht4m13mo ago
copy paste?
JakenVeina
JakenVeina13mo ago
as a template fill in whatever namespace you actually want
_ht4m
_ht4m13mo ago
oh
JakenVeina
JakenVeina13mo ago
and put the code you want to run inside Main()
_ht4m
_ht4m13mo ago
wat is a namespace btw
JakenVeina
JakenVeina13mo ago
a space for names
_ht4m
_ht4m13mo ago
example pls?
JakenVeina
JakenVeina13mo ago
a thing that lets you declare things with the same name, as long as they don't share a namespace
namespace System
{
public static class ObservableExtensions
{
...
}
}

namespace MyApplication
{
public static class ObservableExtensions
{
...
}
}
namespace System
{
public static class ObservableExtensions
{
...
}
}

namespace MyApplication
{
public static class ObservableExtensions
{
...
}
}
or how about an example from a project I'm currently working on
_ht4m
_ht4m13mo ago
that'd be interesting
JakenVeina
JakenVeina13mo ago
namespace Saaft.Data.Accounts
{
public record VersionEntity
{
...
}
}

namespace Saaft.Data.Transactions
{
public record VersionEntity
{
...
}
}
namespace Saaft.Data.Accounts
{
public record VersionEntity
{
...
}
}

namespace Saaft.Data.Transactions
{
public record VersionEntity
{
...
}
}
_ht4m
_ht4m13mo ago
hmm i dont get it but im gonna leave namespaces for later
JakenVeina
JakenVeina13mo ago
two classes one is a model for a version of an Account record one is a model for a version of a Transaction record I can name them both VersionEntity, because they exist in separate namespaces if I ever need to write code that deals with both accounts and transactions, I can refer to these classes as Accounts.VersionEntity and Transactions.VersionEntity (assuming I also have using Saaft.Data;) otherwise, I'd have to name them AccountVersionEntity and TransactionVersionEntity which wouldn't be terrible, but this is a little less verbose, and more flexible
_ht4m
_ht4m13mo ago
i want to say something.. now sometimes i know how it works but i also do not know what to type in vs, it's an issue im dealing with
Accord
Accord13mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
_ht4m
_ht4m13mo ago
Criminal offensive Side eye bombastic side eye
Accord
Accord13mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts