
It looks like you're new here. If you want to get involved, click one of these buttons!
coding in c#. i tried to code some myself, but got a error and don't know how to solve it. i thought i assigned it in the while loop, but it just doesn't work
Heya! ^^
I looked up what you have there and, at first, found something a bit more complex,
but then I came across this here, which I think explains it in a way that's easier to understand (To me, anyhow! I'll post the link to the more complex thing at the bottom): https://www.dummies.com/programming/java/local-variables-in-java/
Don't mind the website name XD They're actually really helpful in lots of areas, not just coding!
But anyhow, since "userName" seems to be a local variable, there are two things I've found that might be causing this!
String userName = "example";
Or this here!
String userName;
userName = "example";
I hope this helps and isn't too confusing ^^' Please let me know if it helps!
And the link to the other website I found: https://stackoverflow.com/questions/9233000/why-compile-error-use-of-unassigned-local-variable
Best of luck to you~!
Answers
when i assigned the string a value in the beginning it was fixed
Oh heck, that's great to hear! Happy to help! <3