© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
24 replies
Mix

Help with why code is returning this way.

Hello, I'm a CS student learning C# for the first time and i'm having some confusion on why my code is returning the way it is. If I input a number and it's a valid number in the array, the program will say it's wrong multiple times before finally printing all of the right data. When I put a
break
break
on the end of the
else 
else 
statement, it just says "Sorry, no data for 2020." and then just ends. But if I remove the
 break 
 break 
, it says its wrong multiple times before finally printing the expected result. If anyone has any insight into why this is happening, I'd really appreciate it!
image.png
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

✅ Why is this not returning 20?
C#CC# / help
2y ago
✅ What is wrong with this code???
C#CC# / help
17mo ago
what is wrong with this code
C#CC# / help
2y ago
what is wrong with this code?
C#CC# / help
4y ago