❔ how can i re use the readline after using it in a if statement
so basically im using readline and if it == "hello" for example, it'd writeline "hi!", then the program would exit. i'd like it to go back to readline after this. how can i do this?
36 Replies
no idea how i can do this
You can keep the readline in a while loop?
Alright lol how do i do that
or wait shit
well that just makes it write no
constantly
this is very much incorrect
You can keep the readline in while loop and keep an if statement for exit, if user writes exit you'll exit out of the loop
you should be using
Console.ReadLine()
directly and storing it in a local variablewdym?
then how will i see what the readline is unless it's in a variable
like that
ah well
local variable
lmao
wdym a local variable
a variable declared in your method
what
i just started c# lmfao like 10 min ago
dont know what im doing
may i suggest $helloworld
Written interactive course https://learn.microsoft.com/en-us/users/dotnet/collections/yz26f8y64n7k07
Videos https://dotnet.microsoft.com/learn/videos
alr so
that breaks the loop and not the if / else statements
i want it to go back to the if userresponse == lol
you don't need to break out of if/else statements
just remove the breaks
then it loops saying bad boy or trash or no
and doesnt go back to user resonse lol
then the code you're running isn't the code you're showing here
every loop that should read a line, then print something out based on the input
like look
ah
fixed it
you're also going to want to modify the variable used for your while loop condition inside the loop
otherwise it'll loop forever
thats the point
:>
to loop forever?
yes
if so you can use
while (true)
mm k
yo
@fixed(void* x = &Jimmacle)
how can i make multiple while loops run at the same time
what are you actually trying to do? the answer to that exact question is complicated for a beginner
ive done what i want now i just want to figure out how to run another while true loop while the one i made before is running
it's easier to help if i actually know the end goal
constantly do that
how do i do the goal i wanted to do lol just tell me that
the short answer is multithreading
but that doesn't seem like something you should do constantly in a loop
i guess you could also use a timer
it's gonna lock the terminal size
basically what i want to do
constantly resize it, anyway
@fixed(void* x = &Jimmacle)
why doesnt this work lol
figured it out
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.