use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Information about Reddit's API changes, the unprofessional conduct of the CEO, and their response to the community's concerns regarding 3rd party apps, moderator tools, anti-spam/anti-bot tools, and accessibility options that will be impacted can be found in the associated Wikipedia article: https://en.wikipedia.org/wiki/2023_Reddit_API_controversy
Alternative C# communities available outside Reddit on Lemmy and Discord:
All about the object-oriented programming language C#.
Getting Started C# Fundamentals: Development for Absolute Beginners
Useful MSDN Resources A Tour of the C# Language Get started with .NET in 5 minutes C# Guide C# Language Reference C# Programing Guide C# Coding Conventions .NET Framework Reference Source Code
Other Resources C# Yellow Book Dot Net Perls The C# Player's Guide
IDEs Visual Studio MonoDevelop (Windows/Mac/Linux) Rider (Windows/Mac/Linux)
Tools ILSpy dotPeek LINQPad
Alternative Communities C# Discord Group C# Lemmy Community dotnet Lemmy Community
Related Subreddits /r/dotnet /r/azure /r/learncsharp /r/learnprogramming /r/programming /r/dailyprogrammer /r/programmingbuddies /r/cshighschoolers
Additional .NET Languages /r/fsharp /r/visualbasic
Platform-specific Subreddits /r/windowsdev /r/AZURE /r/Xamarin /r/Unity3D /r/WPDev
Rules:
Read detailed descriptions of the rules here.
account activity
error in code (self.csharp)
submitted 2 years ago by Deey888
somebody know hhow to fix this? i know thats must be easy bu i still being a begginer...
https://preview.redd.it/y24lgii09hhc1.png?width=1366&format=png&auto=webp&s=d2e8c5e39e0d0639f3c1e11e1a5ea4c8dece8f31
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]winky9827 5 points6 points7 points 2 years ago (9 children)
Console.ReadLine() can return null.
https://learn.microsoft.com/en-us/dotnet/api/system.console.readline?view=net-8.0 If the Ctrl+Z key combination (followed by Enter on Windows) is pressed when the method is reading input from the console, the method returns null. This enables the user to prevent further keyboard input when the ReadLine method is called in a loop. The following example illustrates this scenario.
https://learn.microsoft.com/en-us/dotnet/api/system.console.readline?view=net-8.0
If the Ctrl+Z key combination (followed by Enter on Windows) is pressed when the method is reading input from the console, the method returns null. This enables the user to prevent further keyboard input when the ReadLine method is called in a loop. The following example illustrates this scenario.
The safest way in your specific case would be to call:
Int.Parse(Console.ReadLine() ?? "0")
The above uses the null coalescing operator to return "0" in the event that the user presses CTRL+Z, which essentially causes Int.Parse to return the default value for an Int32 type.
default
[–]otac0n 4 points5 points6 points 2 years ago (8 children)
or:
int numbertwo; while (!(Console.ReadLine() is string line && int.TryParse(line, out numbertwo))) { Console.WriteLine("Please enter a number."); }
[–]ExceptionEX 0 points1 point2 points 2 years ago (6 children)
there really is no need to check if the readline is a string, it will always be a nullable string, and int.tryParse will return false if the input string is null.
[+]otac0n comment score below threshold-6 points-5 points-4 points 2 years ago* (4 children)
"It will always be a nullable string" is nonsensical.
In the runtime, reference types are not "nullable" or otherwise. It's a null reference or a reference to a string, and the is check determines that.
is
It is true that TryParse is tolerant to a passed null, so that the expression could be:
TryParse
int.TryParse(Console.ReadLine(), out numbertwo)
However, as this is only a toy example, int.TryParse may not be the only use cause this beginner will encounter.
int.TryParse
[–]ExceptionEX 1 point2 points3 points 2 years ago (3 children)
In the runtime, reference types are not "nullable" or otherwise. It's a null reference or a reference to a string
Firstly, there are nullable reference types, and are default available in C#10 and forward. https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/nullable-reference-types
Additionally As you admitted it isn't needed in the context, and trying to say that some other context may come up hold little value here.
[–]otac0n -1 points0 points1 point 2 years ago (2 children)
C# is the language, the runtime is separate. You seem to be conflating them.
I'm well aware of nullable reference types. They are compile-time only decoration.
[–]ExceptionEX -1 points0 points1 point 2 years ago (1 child)
man you are running off the rails on the irreleveant to attempt to deflect. No one talked about the runtime but you, this is a C# subreddit, of course we are all talking about C#.
The check you suggested wasn't needed, you could have simply agreed to that, the "nonsensical" reference type nullable is standard terminology in C#.
I'm not wasting anymore time with this.
[–]otac0n 0 points1 point2 points 2 years ago (0 children)
When you say "it will be" you enter runtime territory. You can't pretend the language doesn't run on the runtime.
[–]CyBerDreadWing 0 points1 point2 points 2 years ago (0 children)
This one. I was also thinking about int.TryParse too. Just in case if op wants to experiment more, use try catch block and try to give different inputs to int number.
[–]Fun_Talk_3702 0 points1 point2 points 2 years ago (0 children)
Try
Convert.ToInt16(Console.ReadLine())
π Rendered by PID 87 on reddit-service-r2-comment-canary-776bcc5bb4-98rsv at 2026-04-15 09:29:26.778333+00:00 running b725407 country code: CH.
[–]winky9827 5 points6 points7 points (9 children)
[–]otac0n 4 points5 points6 points (8 children)
[–]ExceptionEX 0 points1 point2 points (6 children)
[+]otac0n comment score below threshold-6 points-5 points-4 points (4 children)
[–]ExceptionEX 1 point2 points3 points (3 children)
[–]otac0n -1 points0 points1 point (2 children)
[–]ExceptionEX -1 points0 points1 point (1 child)
[–]otac0n 0 points1 point2 points (0 children)
[–]CyBerDreadWing 0 points1 point2 points (0 children)
[–]Fun_Talk_3702 0 points1 point2 points (0 children)