0

How can we made loop just once in c# ?(dont use break) Help me please

How can we made loop just once in c# ?(dont use break) Help me please

14th Nov 2018, 8:14 AM
Cihan Hanifi Kılıç
Cihan Hanifi Kılıç - avatar
2 Antworten
+ 6
Hello, Welcome to SoloLearn! 😊 Please, specifying your question correctly!? Use the search bar! https://www.sololearn.com/post/10362/?ref=app Posts in Q/A section should be programming-related and aimed at helping individual learners and community members improve their programming skills! Please, read our guidelines: https://www.sololearn.com/discuss/1316935/?ref=app An useful code for any new user here!;) https://code.sololearn.com/WvG0MJq2dQ6y/ https://www.sololearn.com/learn/CSharp/2596/
14th Nov 2018, 1:40 PM
Danijel Ivanović
Danijel Ivanović - avatar
+ 2
You just set the out condition in the way that it is valid for only one iteration of the loop itself.. One way could be like this with a for loop: for(int i = 0; i < 1; i++) { code to execute} this will run only once since after the first run the condition i will be set to 1 and the loop will break because the condition will be false (because i must be less then 1 to be true)!
14th Nov 2018, 10:53 AM
Sekiro
Sekiro - avatar