© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
7 replies
__dil__

❔ Reading from stdin

So, I'm trying to work with basic IO stuff. I have this snippet:
string line;
while ((line = Console.ReadLine()) != null) {
  // Stuff...
}
string line;
while ((line = Console.ReadLine()) != null) {
  // Stuff...
}

I get a warning about assigning a nullable value to a non-nullable variable. I understand what the warning is saying, but I'm not sure how I'm supposed to do any better than this considering I am already checking for null values. Any recommendations?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Reading from a textfile
C#CC# / help
2y ago
reading files from a directory
C#CC# / help
2y ago
❔ Reading from ClientWebSocket with BinaryReader
C#CC# / help
3y ago
❔ Understanding reading values from binary
C#CC# / help
3y ago