C
C#2y ago
_ht4m

❔ ✅ How am I making errors?

so I'm pretty sure that i'm correct but here are the pics:
392 Replies
_ht4m
_ht4mOP2y ago
_ht4m
_ht4mOP2y ago
phaseshift
phaseshift2y ago
Is this top level script? The class needs to go at the bottom
_ht4m
_ht4mOP2y ago
class wizard ? im a beginner..
phaseshift
phaseshift2y ago
You don't write your own main any more Put the class at the bottom of the file
_ht4m
_ht4mOP2y ago
can u show me an example pls? SORRY I KNOW I SUCK LMAO I just started 5 days ago lol
phaseshift
phaseshift2y 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
ZacharyPatten2y 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
_ht4mOP2y ago
What about those?
ZacharyPatten
ZacharyPatten2y ago
those are called "fields" they are defined inside of classes as you have done
_ht4m
_ht4mOP2y 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
ZacharyPatten2y 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
daniel22y ago
@zacharypatten can I ask a question?
ZacharyPatten
ZacharyPatten2y ago
you only got one question and that was it good job... jk ask your question
daniel2
daniel22y ago
What does this mean Name {get; set;}
ZacharyPatten
ZacharyPatten2y ago
that is a "property"
daniel2
daniel22y ago
Private and public
ZacharyPatten
ZacharyPatten2y ago
"private" and "public" are "access modifiers"
daniel2
daniel22y ago
What’s the difference
ZacharyPatten
ZacharyPatten2y 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
ZacharyPatten2y 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
_ht4mOP2y ago
ZP @zacharypatten
_ht4m
_ht4mOP2y ago
how to fix this?
ZacharyPatten
ZacharyPatten2y ago
you make sure all top level statements come before any type definitions the error is pretty self explanatory
_ht4m
_ht4mOP2y ago
never mind yeah im so dumb lma0o lmao well what do u expect im still a beginner started since 5 days
ZacharyPatten
ZacharyPatten2y 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
_ht4mOP2y 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
ZacharyPatten2y 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
_ht4mOP2y ago
no I just learn how it works lol @zacharypatten
_ht4m
_ht4mOP2y ago
_ht4m
_ht4mOP2y ago
_ht4m
_ht4mOP2y ago
ZacharyPatten
ZacharyPatten2y ago
name and favouritespell are fields of wizard you have to access them from an instance of a wizard "name"->"wizard01.name"
_ht4m
_ht4mOP2y ago
ohhh tysm
_ht4m
_ht4mOP2y ago
_ht4m
_ht4mOP2y ago
now good?
ZacharyPatten
ZacharyPatten2y 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
_ht4mOP2y ago
whats the difference? im using code
ZacharyPatten
ZacharyPatten2y ago
Visual Studio is a fully featured IDE and Visual Studio Code is more of a text editor in comparison
_ht4m
_ht4mOP2y ago
whats an IDE ;-;
ZacharyPatten
ZacharyPatten2y ago
google is your friend
_ht4m
_ht4mOP2y ago
alr
_ht4m
_ht4mOP2y ago
oh
_ht4m
_ht4mOP2y ago
. instantly oh thats cool oh god not again
_ht4m
_ht4mOP2y ago
_ht4m
_ht4mOP2y ago
im getting a red line on console.readke readkey* ..
ZacharyPatten
ZacharyPatten2y ago
take your time learn from your mistakes so you don't make them again
_ht4m
_ht4mOP2y ago
ok thats a simple error
_ht4m
_ht4mOP2y 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
ZacharyPatten2y ago
I would rather keep discussions on this discord server, but you may "@" me if you wish
_ht4m
_ht4mOP2y ago
.... alr
ZacharyPatten
ZacharyPatten2y 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
_ht4mOP2y ago
well I googled VS but I only see VSC
ZacharyPatten
ZacharyPatten2y 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
_ht4mOP2y ago
But those are saved in
_ht4m
_ht4mOP2y ago
@zacharypatten
ZacharyPatten
ZacharyPatten2y ago
I don't know what you are asking, but you need to learn how classes work
_ht4m
_ht4mOP2y ago
fax
ZacharyPatten
ZacharyPatten2y ago
you can use classes that are defined in other files
_ht4m
_ht4mOP2y ago
and I also dont know whats return I know but i like idk when to use it
JakenVeina
JakenVeina2y ago
you use it when you want to awesome
_ht4m
_ht4mOP2y ago
. makes no sense lamo lmao
JakenVeina
JakenVeina2y 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
_ht4mOP2y ago
good reminder I forgot methods again my memory sucks
ZacharyPatten
ZacharyPatten2y 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
_ht4mOP2y ago
its like a fish memory lmao
JakenVeina
JakenVeina2y ago
good advice a little bit of goal can go a long way
_ht4m
_ht4mOP2y ago
1 thing I cant memorize anything my memory suck
ZacharyPatten
ZacharyPatten2y ago
you don't need a good memory to code you need good problem solving skills
_ht4m
_ht4mOP2y ago
I forgot methods 2 times wdym
JakenVeina
JakenVeina2y ago
I mean... you kinda do... but it's not really a memory thing, it's a practice thing
ZacharyPatten
ZacharyPatten2y 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
_ht4mOP2y ago
m kinda good at that, only if there was my own language in VS ..
ZacharyPatten
ZacharyPatten2y ago
C# is an extremely easy language to learn compared to nearly every other language imo
_ht4m
_ht4mOP2y 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
ZacharyPatten2y ago
well if you are not interested in learning C#... why are you?
_ht4m
_ht4mOP2y ago
im im interested in learning it but im just giving an example C# is fun.
ZacharyPatten
ZacharyPatten2y 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
_ht4mOP2y 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
ZacharyPatten2y 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
_ht4mOP2y 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
ZacharyPatten2y 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
_ht4mOP2y ago
No, I meant like the player could move the wizard and casts spells..
ZacharyPatten
ZacharyPatten2y ago
okay, you want movement
_ht4m
_ht4mOP2y ago
Yeah.
ZacharyPatten
ZacharyPatten2y ago
I can link some examples that have movement. would you liek some examples?
_ht4m
_ht4mOP2y ago
sure
_ht4m
_ht4mOP2y ago
uhh.. that looks pretty complicated
_ht4m
_ht4mOP2y ago
lol
ZacharyPatten
ZacharyPatten2y 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
_ht4mOP2y ago
like copypaste?
ZacharyPatten
ZacharyPatten2y ago
yeah
_ht4m
_ht4mOP2y ago
no
ZacharyPatten
ZacharyPatten2y ago
how about you try it
_ht4m
_ht4mOP2y ago
wait how do I use VS i only know VSC
ZacharyPatten
ZacharyPatten2y ago
did you download VS yet?
_ht4m
_ht4mOP2y ago
YES yes * I installed it with C# now what do i do?
ZacharyPatten
ZacharyPatten2y ago
make a new C# console project
_ht4m
_ht4mOP2y ago
looks sick
ZacharyPatten
ZacharyPatten2y ago
it should open to the launcher
_ht4m
_ht4mOP2y ago
on or off?
ZacharyPatten
ZacharyPatten2y ago
up to you
_ht4m
_ht4mOP2y 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
_ht4mOP2y ago
_ht4m
_ht4mOP2y 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
ZacharyPatten2y 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
_ht4mOP2y ago
it didnt generate top level statements.. bruh . well uh honestly VSC gui is much better than this tbh
ZacharyPatten
ZacharyPatten2y 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
_ht4mOP2y ago
lol anw so um thats all now I start?
ZacharyPatten
ZacharyPatten2y ago
so how about you try running your code? you can do so with the green triangle at the top
ZacharyPatten
ZacharyPatten2y ago
ZacharyPatten
ZacharyPatten2y ago
yours probably says "ConsoleApp1" unless you put in a custom name, which is fine if you did
_ht4m
_ht4mOP2y ago
oh its working
_ht4m
_ht4mOP2y ago
_ht4m
_ht4mOP2y ago
cool
ZacharyPatten
ZacharyPatten2y ago
nice
_ht4m
_ht4mOP2y ago
but now how do I make my OWN wasd game? or movement whatever
ZacharyPatten
ZacharyPatten2y 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
_ht4mOP2y ago
thats quite hard to understand for beginners..
ZacharyPatten
ZacharyPatten2y ago
breakpoints are your friend
_ht4m
_ht4mOP2y ago
aaaaaaaaaaaand what is a breakpoint ..
Feast
Feast2y ago
Debugger.Break()
JakenVeina
JakenVeina2y ago
it's a point where you break
_ht4m
_ht4mOP2y ago
.
JakenVeina
JakenVeina2y 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
ZacharyPatten2y 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
ZacharyPatten2y ago
and you can step through the code while it is running line-by-line with the F11 key
_ht4m
_ht4mOP2y ago
maybe programming isnt for me.. i never understand anything in it lmao
JakenVeina
JakenVeina2y ago
that's normal
ZacharyPatten
ZacharyPatten2y ago
you can't expect to become a programmer over the course of an hour or two. it takes time
JakenVeina
JakenVeina2y 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
_ht4mOP2y ago
ZP how tf do u expect me to understand all of this?
ZacharyPatten
ZacharyPatten2y ago
ask questions read each line of code. what is the first line of code you don't understand?
_ht4m
_ht4mOP2y ago
1 sec gotta do smthing ima leave WASD later
ZacharyPatten
ZacharyPatten2y 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
JakenVeina2y ago
or solitaire or battleship
_ht4m
_ht4mOP2y ago
bro vs sucks compared to vsc tbh but .
JakenVeina
JakenVeina2y ago
looooooooooooooool, no not for C# and not for beginners
_ht4m
_ht4mOP2y ago
which one u mean vs or vsc ngl I prefer vsc but ok easier to use tbh
JakenVeina
JakenVeina2y 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
_ht4mOP2y ago
VSC = visual studio code @ReactiveVeina
JakenVeina
JakenVeina2y ago
....yes, as does "VS Code"
_ht4m
_ht4mOP2y ago
not the tools
JakenVeina
JakenVeina2y ago
that's my point
_ht4m
_ht4mOP2y ago
brih I meant something else
JakenVeina
JakenVeina2y ago
VS Code doesn't inherently include tooling
_ht4m
_ht4mOP2y ago
other than tools like the gui and how it looks is what I meant.
JakenVeina
JakenVeina2y ago
it's not significantly different than VS
_ht4m
_ht4mOP2y ago
it is
JakenVeina
JakenVeina2y 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
_ht4mOP2y ago
vsc looks better than vs
JakenVeina
JakenVeina2y 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
_ht4mOP2y ago
Idk i just dont rly like vs but I need to use it so .
JakenVeina
JakenVeina2y 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
_ht4mOP2y ago
why do I feel like VS is different from vsc cuz in vsc its correct but here its wrong:
JakenVeina
JakenVeina2y ago
uhh it's not correct
_ht4m
_ht4mOP2y ago
_ht4m
_ht4mOP2y ago
..
JakenVeina
JakenVeina2y ago
yes
_ht4m
_ht4mOP2y ago
y is it correct in VSC?
JakenVeina
JakenVeina2y ago
it's not
ZacharyPatten
ZacharyPatten2y ago
it wasnt
JakenVeina
JakenVeina2y ago
VS Code just isn't reporting the errors to you, until you compile
_ht4m
_ht4mOP2y ago
ZP ur finally back
JakenVeina
JakenVeina2y ago
VS Code doesn't give you live feedback
_ht4m
_ht4mOP2y ago
which I can agree with . lol But I ran the program a LOT of times yet only yellow lines, no red line ..
JakenVeina
JakenVeina2y ago
define "ran the program"
_ht4m
_ht4mOP2y ago
maybe nobody saw that i realized the error LOL I didn't sleep for like 8 hours lol
JakenVeina
JakenVeina2y ago
awesome
_ht4m
_ht4mOP2y ago
yall thanks
JakenVeina
JakenVeina2y ago
it happens
_ht4m
_ht4mOP2y ago
WAIT I also have another problem that I struggled with a lot
JakenVeina
JakenVeina2y ago
42
_ht4m
_ht4mOP2y ago
i still dont know how to fix it.. 42 ?
JakenVeina
JakenVeina2y ago
42 that's the answer to your problem
ZacharyPatten
ZacharyPatten2y ago
42 is a hitchikers guide to the galaxy joke. google it
_ht4m
_ht4mOP2y ago
now better
ZacharyPatten
ZacharyPatten2y ago
or better yet... read the booke 😛
JakenVeina
JakenVeina2y ago
or watch the movie both are good
ZacharyPatten
ZacharyPatten2y ago
i love da movie 🙂
_ht4m
_ht4mOP2y 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
JakenVeina2y ago
depends where you mean
_ht4m
_ht4mOP2y ago
i think its the same
_ht4m
_ht4mOP2y ago
JakenVeina
JakenVeina2y 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
_ht4mOP2y ago
oh
JakenVeina
JakenVeina2y ago
var myVariable = 0;
var myVariable = 0;
_ht4m
_ht4mOP2y ago
. nvm then i would get a compiler error if i switch float and int with var
_ht4m
_ht4mOP2y ago
JakenVeina
JakenVeina2y 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
_ht4mOP2y 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
JakenVeina2y ago
an accurate one, tho 😛
_ht4m
_ht4mOP2y 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
JakenVeina2y ago
godspeed
_ht4m
_ht4mOP2y ago
reactive what does public mean? i forgot . public int etc
JakenVeina
JakenVeina2y ago
access modifier means anyone can access it
_ht4m
_ht4mOP2y ago
oh . and private is da opposite?
JakenVeina
JakenVeina2y ago
basically
_ht4m
_ht4mOP2y ago
ik i get what u mean
JakenVeina
JakenVeina2y ago
means only the immediate class it's defined in can access it
_ht4m
_ht4mOP2y 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
JakenVeina2y ago
?
_ht4m
_ht4mOP2y ago
. u got a pet btw?
JakenVeina
JakenVeina2y ago
yes
_ht4m
_ht4mOP2y ago
wat pet
JakenVeina
JakenVeina2y ago
dog
_ht4m
_ht4mOP2y ago
I have 3 birds
JakenVeina
JakenVeina2y ago
neat
_ht4m
_ht4mOP2y 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
JakenVeina2y ago
assuming you get the naming right, yes
_ht4m
_ht4mOP2y ago
weird,
JakenVeina
JakenVeina2y ago
Castspells and castspells are not the same thing
_ht4m
_ht4mOP2y ago
_ht4m
_ht4mOP2y ago
ik u need to get the correct caps i got a red line
JakenVeina
JakenVeina2y ago
var x = Castspells-- is shorthand for...
var x = Castspells;
Castspells = Castspells - 1;
var x = Castspells;
Castspells = Castspells - 1;
_ht4m
_ht4mOP2y ago
JakenVeina
JakenVeina2y ago
right Castspells is defined as an instance member of the wizard class
_ht4m
_ht4mOP2y ago
correct.. wait i gotchu
JakenVeina
JakenVeina2y ago
you can only refer to it by specifying WHICH instance of the wizard class you want to reference
_ht4m
_ht4mOP2y ago
no need to type
_ht4m
_ht4mOP2y ago
JakenVeina
JakenVeina2y ago
or by being inside another instance member of the class precisely
_ht4m
_ht4mOP2y ago
now good? nvm prob wrong lmao no way its correct trying wont hurt tho
JakenVeina
JakenVeina2y ago
I mean... there's no error beyond that, I dunno
_ht4m
_ht4mOP2y ago
but look, it kinda makes sense
JakenVeina
JakenVeina2y ago
I'd have to know what your intentions are for what that code is supposed todo
_ht4m
_ht4mOP2y 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
JakenVeina2y ago
right
_ht4m
_ht4mOP2y ago
pro skills lol jk im rly bad
_ht4m
_ht4mOP2y ago
umm
_ht4m
_ht4mOP2y ago
what abt this one tho
JakenVeina
JakenVeina2y ago
uhhh hmmm show me the whole file with Main() in it
_ht4m
_ht4mOP2y ago
_ht4m
_ht4mOP2y ago
_ht4m
_ht4mOP2y ago
there goes the others
JakenVeina
JakenVeina2y ago
?
_ht4m
_ht4mOP2y ago
das the file
JakenVeina
JakenVeina2y ago
try dropping that semicolon in the middle there
_ht4m
_ht4mOP2y ago
that makes no sense but ok well it worked ..
JakenVeina
JakenVeina2y ago
nah, it makes sense
_ht4m
_ht4mOP2y ago
Y?
JakenVeina
JakenVeina2y ago
it's just invalid syntax semicolons belong at the end of statements
_ht4m
_ht4mOP2y 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
JakenVeina2y ago
the thing that came right before that semicolon was the Main() method definition which is not a statement
_ht4m
_ht4mOP2y ago
i was changing them but never noticed the semicolon
JakenVeina
JakenVeina2y ago
and should not have a semicolon after it
_ht4m
_ht4mOP2y ago
yeah i know that i was just changing the lines positions never noticed that semicolon lmao
JakenVeina
JakenVeina2y ago
I'm actually not sure why that wasn't a straight-up error, upon the semicolon
_ht4m
_ht4mOP2y ago
theres a fly annoying me . oh god wait
JakenVeina
JakenVeina2y ago
maybe that's actually valid for local functions?
_ht4m
_ht4mOP2y 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
JakenVeina2y ago
uhhhhhh no but really, I don't know what you're asking
_ht4m
_ht4mOP2y 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
JakenVeina2y ago
okay
_ht4m
_ht4mOP2y ago
no need to eplain this was so obvious
_ht4m
_ht4mOP2y ago
_ht4m
_ht4mOP2y 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
_ht4mOP2y ago
me everyday:
_ht4m
_ht4mOP2y 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
Pobiega2y 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
_ht4mOP2y ago
I still have 1 issue then im done
Pobiega
Pobiega2y ago
Okay, describe the issue
_ht4m
_ht4mOP2y 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
_ht4mOP2y ago
now the You have + spells dont worry I know its supposed to be wizard01.spells but
Pobiega
Pobiega2y ago
uhm
_ht4m
_ht4mOP2y ago
public void castspell(); and wizard01.castspell; and wizard01.Castspell--;
Pobiega
Pobiega2y ago
you are mixing top level statements with classic main you cant do that pick a style and stick to it
JakenVeina
JakenVeina2y ago
apparently it actually compiles
Pobiega
Pobiega2y ago
what okay, thats... uncomfortable, but whatever
_ht4m
_ht4mOP2y ago
veina how?
Pobiega
Pobiega2y ago
your current problem is that public void CastSpell(); doesnt have a body
JakenVeina
JakenVeina2y ago
earlier, he had a stray semicolon that caused a "there is no suitable Main() method" error
Pobiega
Pobiega2y ago
you can't declare empty methods
JakenVeina
JakenVeina2y ago
he removed that and the error went await
_ht4m
_ht4mOP2y ago
Then why am I getting redline?
Pobiega
Pobiega2y ago
and all 3 places you try to "call" the method, you forgot the ()
JakenVeina
JakenVeina2y ago
I was referring to your use of the main method
_ht4m
_ht4mOP2y ago
correct, thanks for reminding also
JakenVeina
JakenVeina2y ago
look
_ht4m
_ht4mOP2y ago
(btw my memory is so bad so I cant remember that when u try to call a method u need() )
JakenVeina
JakenVeina2y ago
it's time we take a different approach here
_ht4m
_ht4mOP2y ago
anyways
JakenVeina
JakenVeina2y ago
this is not about memory
_ht4m
_ht4mOP2y ago
look
JakenVeina
JakenVeina2y ago
you have errors
_ht4m
_ht4mOP2y ago
yes I know
JakenVeina
JakenVeina2y ago
what do the errors say
_ht4m
_ht4mOP2y ago
1 sec
JakenVeina
JakenVeina2y 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
_ht4mOP2y 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
JakenVeina2y ago
that's what you should focus on, then
Pobiega
Pobiega2y ago
^
JakenVeina
JakenVeina2y ago
understanding error messages
Pobiega
Pobiega2y ago
learn how to read and understand the errors. thats a CORE skill
_ht4m
_ht4mOP2y ago
_ht4m
_ht4mOP2y ago
how do I practice understanding error msgs?
Pobiega
Pobiega2y ago
lets begin with the top one what do you think it means
_ht4m
_ht4mOP2y ago
hmm.. i think it means i have to get public void Castspell(); into main?
Pobiega
Pobiega2y ago
?
_ht4m
_ht4mOP2y ago
wait nmv nvm um
Pobiega
Pobiega2y ago
how on earth do you get that from
The name 'Spells' does not exist in the current context
_ht4m
_ht4mOP2y 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
_ht4mOP2y ago
_ht4m
_ht4mOP2y ago
Pobiega
Pobiega2y ago
okay. can you show the updated error list?
_ht4m
_ht4mOP2y ago
_ht4m
_ht4mOP2y ago
idk the first and 2nd i've been getting those for a while
Pobiega
Pobiega2y ago
lets start with the third one down
_ht4m
_ht4mOP2y ago
ye sorry my brain died there
Pobiega
Pobiega2y ago
Cannot assign to CastSpells because its a method group
what does this tell you
_ht4m
_ht4mOP2y ago
this one is pretty self explanatory.. but i have time to think soo
Pobiega
Pobiega2y ago
hint: what is a "method group"?
_ht4m
_ht4mOP2y 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
Pobiega2y ago
no it means the symbol is a method
_ht4m
_ht4mOP2y ago
bruh my brain dies
Pobiega
Pobiega2y ago
ie CastSpells is a method not a variable, not a property, not a class
_ht4m
_ht4mOP2y ago
yep..
Pobiega
Pobiega2y ago
and you can't assign, ie change the value, of a method it says line 10, so we look at line 10
Pobiega
Pobiega2y ago
_ht4m
_ht4mOP2y ago
Pobiega
Pobiega2y ago
so why wont that work whats wrong here
_ht4m
_ht4mOP2y ago
im changing the value of the method here..
Pobiega
Pobiega2y ago
you are.
_ht4m
_ht4mOP2y ago
Pobiega
Pobiega2y ago
or well, you're trying
_ht4m
_ht4mOP2y ago
Hmm, but I want the spells go down when the user casts a spell
Pobiega
Pobiega2y 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
_ht4mOP2y ago
oh umm.. that makes sense now But wait, what's the difference between static and public? @pobiega
Pobiega
Pobiega2y ago
stop pinging
_ht4m
_ht4mOP2y ago
ok sorry
Pobiega
Pobiega2y 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
_ht4mOP2y ago
oh now back to the error
_ht4m
_ht4mOP2y ago
ok oops i just randomly fixed 1 error wat
Pobiega
Pobiega2y ago
well, quite a bit of them were interconnected one error often leads to more errors
_ht4m
_ht4mOP2y ago
well yknow the castspell method instead of semicolon, i replaced it with curly brackets
Pobiega
Pobiega2y ago
good
_ht4m
_ht4mOP2y ago
turns out it was correct wat
Pobiega
Pobiega2y 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
_ht4mOP2y ago
oh now to the 3 errors
Pobiega
Pobiega2y ago
why would you want to anyways? a body-less method by definition does nothing
_ht4m
_ht4mOP2y ago
wait is it correct hold on im gonna do smthing ok wait maybe I have to put something in the curly brackets
Pobiega
Pobiega2y ago
eventually, yes but not right now
_ht4m
_ht4mOP2y ago
wise
_ht4m
_ht4mOP2y ago
.. anyways it's quite hard for beginners ig not i guess but for sure
Pobiega
Pobiega2y ago
¯\_(ツ)_/¯
_ht4m
_ht4mOP2y ago
or my brain is just too small
Pobiega
Pobiega2y ago
I think you are just rushing ahead.
_ht4m
_ht4mOP2y ago
not really its been 5 days since i started
Pobiega
Pobiega2y ago
I only briefly scrolled through the history on this thread, but I saw the word "brackeys"
_ht4m
_ht4mOP2y ago
correct.
Pobiega
Pobiega2y ago
so I guess you're following his bad and outdated tutorials?
_ht4m
_ht4mOP2y ago
then wat do i do that is 100% correct.
Pobiega
Pobiega2y ago
$helloworld
Pobiega
Pobiega2y ago
these are good.
_ht4m
_ht4mOP2y 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
JakenVeina2y ago
stop pinging people if you have a question, ask it
_ht4m
_ht4mOP2y 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
JakenVeina2y ago
standby a moment, I need to test something okay I'd like you to look at your warnings list, please
_ht4m
_ht4mOP2y ago
alright
_ht4m
_ht4mOP2y ago
JakenVeina
JakenVeina2y ago
top one
_ht4m
_ht4mOP2y ago
wdym top one?
JakenVeina
JakenVeina2y ago
I mean, look at the top warning in that list
_ht4m
_ht4mOP2y ago
"The local function 'Main' is declared but never used"
JakenVeina
JakenVeina2y ago
yes, that one
_ht4m
_ht4mOP2y ago
i have nothing in mind to fix it
JakenVeina
JakenVeina2y 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
_ht4mOP2y ago
hmm wait i think
JakenVeina
JakenVeina2y 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
_ht4mOP2y ago
ohhhh i get it now
JakenVeina
JakenVeina2y ago
here is your template
_ht4m
_ht4mOP2y ago
but look
JakenVeina
JakenVeina2y ago
namespace MyNamespace
{
public static class EntryPoint
{
public static void Main()
{

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

}
}
}
use this
_ht4m
_ht4mOP2y ago
copy paste?
JakenVeina
JakenVeina2y ago
as a template fill in whatever namespace you actually want
_ht4m
_ht4mOP2y ago
oh
JakenVeina
JakenVeina2y ago
and put the code you want to run inside Main()
_ht4m
_ht4mOP2y ago
wat is a namespace btw
JakenVeina
JakenVeina2y ago
a space for names
_ht4m
_ht4mOP2y ago
example pls?
JakenVeina
JakenVeina2y 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
_ht4mOP2y ago
that'd be interesting
JakenVeina
JakenVeina2y 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
_ht4mOP2y ago
hmm i dont get it but im gonna leave namespaces for later
JakenVeina
JakenVeina2y 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
_ht4mOP2y 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
Accord2y 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
_ht4mOP2y ago
Criminal offensive Side eye bombastic side eye
Accord
Accord2y 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