Was googling how to do this and found this post. Using this info and some other posts I put this together. Maybe someone else will land here and find this useful. BTW, this is C# 10.0.

Code:
public static class ConsoleEx
{
    private static TextWriter? defaultConsoleOut = null;

    public static void SetEcho(bool flag)
    {
        if (defaultConsoleOut == null) defaultConsoleOut = Console.Out;
...