This is a simple while loop in C# but it is working infinitely.
int count = 1;
while (count < 10)
{
count = count++;
}
Why is this so?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This will loop infinitely.
There are two types of incrementing a variable:
Here
count++and++countboth are different if you have used++countit will work.Here
count = count++means count variable will be incremented by one then assigns the earlier value 1 to the count variable itself so count remains unchanged.