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*/ }