6 Replies
ok?
$ask
How to get the best help
Make a post in #help or one of the topic channels under Development.
Avoid asking Can anybody help Has anyone used Why doesn't my code work?
C# is a big area! No one knows they can help unless you tell them about the small area you're trying to work in.
Explain what you are doing, and potentially why for as much context as possible. Avoid screenshots where possible, share code directly in Discord. Type
$code
into chat to learn how to post code.
See https://www.nohello.net and https://dontasktoask.com if you want common help chat room etiquette.that's just a warning, not an error
fyi
Assuming your question is "why am I getting this warning",
Console.ReadLine()
can in some circumstances return null
, which is what the warning is telling you.
There are three ways to fix it:
1. Make the type of userName
string?
instead of string
, which just means that the variable can be null
.
2. Add ?? ""
after Console.ReadLine()
which just means that the value should be an empty string if Console.ReadLine()
returns null
.
3. Add a !
after Console.ReadLine()
in order to just make the compiler shut up about the warning.
Although as mentioned, that's a warning, not an error, which means that your code will compile just fine, but you may get runtime errors because of it.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.