© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
8 replies
__dil__

✅ Introduce variable in `while` condition

Is it possible to achieve something like this? (pseudo-C#)
while (Computation() val when val != otherVal)
  // You can use `val` here...
while (Computation() val when val != otherVal)
  // You can use `val` here...

The idea is that the loop should go until the result of some computation does not match some predicate, and to also keep the result of the computation around in the loop.

If not, how would you achieve a similar pattern?
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

❔ different variable type depending on condition of IF statement
C#CC# / help
4y ago
❔ multiple conditions do while loop
C#CC# / help
3y ago
Possible race condition?
C#CC# / help
16mo ago
❔ Implicate without condition
C#CC# / help
3y ago