none
loop RRS feed

  • Question

  • my program has while loop that sometimes doesn't end.

    Is there a way to esc to end loop?

    Tuesday, October 15, 2019 3:42 PM

All replies

  • Please show your code so we know the context of what you are doing.

    Also look at the docs e.g. break and return are two methods to exit a loop.

    https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/while


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Tuesday, October 15, 2019 4:40 PM
    Moderator
  • There are many possibilities and the best solution depends on what you are doing and you do not tell us what you are doing.

    One possibility is to create a counter that is initialized to zero and then in the while condition test to determine of the counter is above a specified value. Be sure to increment the counter in the while block.



    Sam Hobbs
    SimpleSamples.Info

    Tuesday, October 15, 2019 7:07 PM