Is this emitted code useful?

While viewing some DLL using ILSpy, I came across the following code:

void RenderFiles(List<List<string>> pdfFiles)
{
  int num;
  for (int i = 0; i < pdfFiles.Count; i = num + 1)
  {
    // ....
    num = i;
  }
}

The introduction of the variable num seems strange to me. Why does the compiler introduce an additional local variable?

The source code is just a simple loop, although it uses the count variable, not the foreach enumerator:

void RenderFiles(List<List<string>> pdfFiles)
{
  for (int i = 0; i < pdfFiles.Count; i++)
  {
  }
}
+4
source share

Source: https://habr.com/ru/post/1622746/


All Articles