❔ Code Block not being executed.
Hi, the code block after is just not being executed, I used Console.WriteLIne to confirm my lines 49 and 50 were being printed correctly.....I have just started. This was in a tutorial, I rechecked the code 10 times and still can't figure out the problem.
The solution just shows up as what I uploaded in the second picture, I can type more stuff, idk how and why but I can. Either way, that's not what I wanted to happen.
What I wanted was for it to just continue on with the code block and print the result with the final Console.Readline
Sorry for asking such A B C questions of programming...I am still learning ABC...but I really dont know, cant progress further in lesson like this >:(
22 Replies
can you show your code and not as a screenshot? $code
Posting Code Snippets
To post a code snippet type the following:
```cs
// code here
```
Notes:
- Get an example by typing
$codegif
in the chat.
- Change the language by replacing cs
with the language of your choice (for example sql
or cpp
).
- If your code is too long, you can post it to https://paste.mod.gg/ and share the link.you also mention line numbers in your post, but omitted them in the screenshot :p
Do I just copy paste the entire code?
Oops sorry.
$cidegif
sure. if its too long, use the URL the bot posted
BlazeBin - bitticmtbvqx
A tool for sharing your source code with the world!
Does this work?
First time interacting with a coding community, not aware of basic things yet lol.
yep that works
while (counter > result)
does this logically make sense for what you are trying to do. Is 1 > 3
true or falsetrue
wait
1 > 3? til
oh
It was supposed to be the other way around
wasn't it
Because 1 isnt a bigger value than 3
correct
Thank you very much, I uh, well brainfarted.
I didnt expect such instant
You should also prevent entering a number smaller than 0, otherwise your While loop will continue to run indefinitely.
Ohhh, I'll try to see if I can do something like that. Thanks for the advice.
If you change your While clause to <= you can ignore the check for less than 0.
But you should check before the int.parse if the input is a number.
I was thinking if there was a way to make the user only be able to input integers, I searched, but everything was going above my head so I thought I'll think about that another time.
you could use somthing like that
The tryparse function tries to convert the value to an int, if this doesn't work the "out" parameter will be 0
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.