C# Недостижимый код обнаруживается

Отладка.NEt Приложения имеет главу по тому, как использовать WinDbg

10
задан Dave Clemmer 13 March 2013 в 23:16
поделиться

3 ответа

The problem is that this actually isn't a loop. You don't have any condition on the break so you could equivalently write something like

if(cmbPath.Items.Count > 0)
{
   OurKey.SetValue("paths" + 0, cmbPaths.Items[0]);
}

Alternatively you have to correct with something like

for (int i = 0; i < cmbPaths.Items.Count; i++) 
{
   OurKey.SetValue("paths" + i, cmbPaths.Items[i]);

   if(someConditionHolds)
      break;
}
24
ответ дан 3 December 2019 в 14:00
поделиться

You're breaking out of the loop before the end of the first iteration.

11
ответ дан 3 December 2019 в 14:00
поделиться

The problem is that because you break; in the loop with no chance of it doing anything else, the increment of i (i++) will never be reached.

3
ответ дан 3 December 2019 в 14:00
поделиться
Другие вопросы по тегам:

Похожие вопросы: