✅ need help with a problem
why does it print "you are young" no matter what the input is?
20 Replies
ages.Add(age)
what's the age here?
age seems to never be assigned, so it's always zerothats supposed to add the user input to a list
unless i did it wrong
what's the point of doing the list? just check the age
yeah you're right
im not sure why i did that
gimme a sec
i believe i know what i did wrong
ill lyk if it works
alright i got it working
i assigned age wrong and messed up the initial check
all's good now though
Closed!
don't name your member variables like your locals btw
prefixing with an underscore is best practice
i didnt name any of those. it was a practice problem i was trying to solve.
wdym?
_age
if it's a private fieldalright
public fields aren't usually used at all
good to know.
my job was just to write the methods
I personally name them like properties when I do use them
so i should do this instead?
if i were to write the whole thing myself
private
i just told you you don't typically use public fields
i said before, i didnt write this. i just wrote inside the method, not around it.
bruh you just typed above "if i were to write the whole thing myself"
yeah
i forgot i said that
so why should i add _ to age
im curious
is it just conventionally how private fields are named?
mostly to visually distinguish them from local variables
alright thanks for that tip
Closed!