interactive icon indicating copy to clipboard operation
interactive copied to clipboard

foreach loop printing elements multiple times

Open EngBuilds opened this issue 2 months ago • 2 comments

Describe the bug

The foreach loop isn't functioning correctly.

Code:

// Generate 5 numbers and print them
var numbers = new List<int> { 10, 20, 30, 40, 50 };

foreach (var num in numbers)
{
    Console.WriteLine($"Number: {num}");
}

Output screenshot :

Image

Other observations: I tried creating a new .dib notebook and couldn't recreate this. In the notebook that is having this issue, I tried clearing cell outputs, restarting the kernel etc. but it still kept showing this error.

Curious what may have triggered this behavior in the first place.

Please complete the following:

Which version of .NET Interactive are you using? (In a notebook, run the #!about magic command. ): Version: 1.0.632301+7d35ce3be7eb7a603527a3683b691d5e9922adca Library version: 1.0.0-beta.25323.1+7d35ce3be7eb7a603527a3683b691d5e9922adca

  • OS
    • [x] Windows 11
    • [ ] Windows 10
    • [ ] macOS
    • [ ] Linux (Please specify distro)
    • [ ] iOS
    • [ ] Android
  • Browser
    • [ ] Chrome
    • [ ] Edge
    • [ ] Firefox
    • [ ] Safari
  • Frontend
    • [ ] Jupyter Notebook
    • [ ] Jupyter Lab
    • [ ] nteract
    • [x] Visual Studio Code
    • [ ] Visual Studio Code Insiders
    • [ ] Visual Studio
    • [x] Other (please specify): .dib file polyglot notebook

Screenshots

If applicable, please add screenshots of the entire VS Code window.

EngBuilds avatar Nov 06 '25 18:11 EngBuilds

Are you able to share the notebook that reproduces this behavior?

jonsequitur avatar Nov 06 '25 18:11 jonsequitur

Are you able to share the notebook that reproduces this behavior?

.dib files can be attached here.

EngBuilds avatar Nov 06 '25 19:11 EngBuilds