tareqimbasher / NetPad

A cross-platform C# editor and playground.
MIT License
1.31k stars 66 forks source link

Console.Write(Line) output doesn't return in correct order #195

Closed toanq closed 5 months ago

toanq commented 5 months ago

I'm using NetPad v0.7.0 on Windows 11 Version 23H2 (OS Build 22635.2921).

Running this snippet:

public class XXX {
    public IEnumerable<int> Integers()
    {
        yield return 1;
        yield return 2;
        yield return 4;
        yield return 8;
        yield return 16;
        yield return 16777216;
    }
    public static void Main()
    {
        var x = new XXX();
        x.Consumer();
    }
    public void Consumer()
    {
        foreach (int i in Integers())
        {
            Console.Write($"{i}\n".Dump());
        }
    }
}

Result: image

The Console.Write result should be the same as the one with Dump.

tareqimbasher commented 5 months ago

Please see #89. The problem is you're defining a new entry point by declaring static void Main()

toanq commented 5 months ago

Wow, I didn't know that, thank you very much for your detailed explanation.