Skip to main content
Corrected a false statement.
Source Link
Vaillancourt
  • 16.4k
  • 17
  • 56
  • 61

While loops must be used WITH CAUTION. AlotA lot of times if whilewhile is not used in a correct manner it will always be truetrue. Infinite loops willcan cause anya program to crash, freeze or hang, like you experienced.

If dealing with arrays, use 'foreach'foreach instead if possible.

IncaseIn case you're new to foreachforeach syntax:

foreach (type elementname in variablename) { /*code here*/ }

While loops must be used WITH CAUTION. Alot of times if while is not used in a correct manner it will always be true. Infinite loops will cause any program to crash.

If dealing with arrays, use 'foreach' instead if possible.

Incase you're new to foreach syntax:

foreach (type elementname in variablename) { /*code here*/ }

While loops must be used WITH CAUTION. A lot of times if while is not used in a correct manner it will always be true. Infinite loops can cause a program to crash, freeze or hang, like you experienced.

If dealing with arrays, use foreach instead if possible.

In case you're new to foreach syntax:

foreach (type elementname in variablename) { /*code here*/ }
Source Link

While loops must be used WITH CAUTION. Alot of times if while is not used in a correct manner it will always be true. Infinite loops will cause any program to crash.

If dealing with arrays, use 'foreach' instead if possible.

Incase you're new to foreach syntax:

foreach (type elementname in variablename) { /*code here*/ }